답안 #374412

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
374412 2021-03-07T09:25:04 Z topovik Euklid (COCI20_euklid) C++14
0 / 110
264 ms 32108 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 = 2e3 + 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 main()
{
    int t;
    cin >> t;
    for (int i = 1; i < N; i++)
        for (int j = 1; j < N; j++) gcd[i][j] = __gcd(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;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 261 ms 32108 KB Output is correct
2 Incorrect 247 ms 31980 KB Integer parameter [name=a] equals to -1, violates the range [1, 10^18]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 256 ms 31980 KB Output is correct
2 Correct 251 ms 31980 KB Output is correct
3 Incorrect 251 ms 31980 KB Integer parameter [name=a] equals to -1, violates the range [1, 10^18]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 250 ms 31980 KB Integer parameter [name=a] equals to -1, violates the range [1, 10^18]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 264 ms 31980 KB Output is correct
2 Correct 255 ms 31980 KB Output is correct
3 Correct 260 ms 32108 KB Output is correct
4 Correct 256 ms 31980 KB Output is correct
5 Correct 248 ms 31980 KB Output is correct
6 Correct 248 ms 32028 KB Output is correct
7 Correct 251 ms 31980 KB Output is correct
8 Correct 245 ms 31976 KB Output is correct
9 Correct 250 ms 31980 KB Output is correct
10 Incorrect 249 ms 32008 KB Integer parameter [name=a] equals to -1, violates the range [1, 10^18]
# 결과 실행 시간 메모리 Grader output
1 Correct 264 ms 31980 KB Output is correct
2 Correct 255 ms 31980 KB Output is correct
3 Correct 260 ms 32108 KB Output is correct
4 Correct 256 ms 31980 KB Output is correct
5 Correct 248 ms 31980 KB Output is correct
6 Correct 248 ms 32028 KB Output is correct
7 Correct 251 ms 31980 KB Output is correct
8 Correct 245 ms 31976 KB Output is correct
9 Correct 250 ms 31980 KB Output is correct
10 Incorrect 249 ms 32008 KB Integer parameter [name=a] equals to -1, violates the range [1, 10^18]
# 결과 실행 시간 메모리 Grader output
1 Correct 261 ms 32108 KB Output is correct
2 Incorrect 247 ms 31980 KB Integer parameter [name=a] equals to -1, violates the range [1, 10^18]
3 Halted 0 ms 0 KB -