Submission #374414

# Submission time Handle Problem Language Result Execution time Memory
374414 2021-03-07T09:27:43 Z topovik Sjekira (COCI20_sjekira) C++14
0 / 110
1000 ms 71284 KB
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll N = 3e3 + 10;
const ll oo = 1e10;

int gcd[N][N], val[N][N];

int f(int x, int y)
{
    if (y > x) swap(x, y);
    if (val[x][y] != 0) return val[x][y];
    if (y == 1) return val[x][y] = x;
    else return val[x][y] = f(x / y, y);
}

int gd(int x, int y)
{
    if (x < y) swap(x, y);
    if (y == 0) return x;
    if (gcd[x][y] != 0) return gcd[x][y];
    return val[x][y] = gd(x % y, y);
}

int main()
{
    int t;
    cin >> t;
    for (int i = 1; i < N; i++)
        for (int j = 1; j < N; j++) gcd[i][j] = gd(i, j), val[i][j] = f(i, j);
    while (t--)
    {
        int x, y;
        cin >> x >> y;
        int l = -1, r = -1;
        for (int i = 1; i <= 1000; i++)
            for (int j = 1; j <= 1000; j++)
              if (gcd[i][j] == x && val[i][j] == y) l = i, r = j;
        cout << l << " " << r << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 301 ms 71276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 71284 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 301 ms 71276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 301 ms 71276 KB Output isn't correct
2 Halted 0 ms 0 KB -