#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 = 1e3 + 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 |
91 ms |
8300 KB |
Output is correct |
2 |
Incorrect |
87 ms |
8300 KB |
Integer parameter [name=a] equals to -1, violates the range [1, 10^18] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
89 ms |
8300 KB |
Output is correct |
2 |
Correct |
96 ms |
8300 KB |
Output is correct |
3 |
Incorrect |
90 ms |
8300 KB |
Integer parameter [name=a] equals to -1, violates the range [1, 10^18] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
87 ms |
8300 KB |
Integer parameter [name=a] equals to -1, violates the range [1, 10^18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
97 ms |
8300 KB |
Output is correct |
2 |
Correct |
93 ms |
8300 KB |
Output is correct |
3 |
Correct |
96 ms |
8300 KB |
Output is correct |
4 |
Correct |
88 ms |
8300 KB |
Output is correct |
5 |
Correct |
88 ms |
8260 KB |
Output is correct |
6 |
Correct |
88 ms |
8300 KB |
Output is correct |
7 |
Correct |
87 ms |
8300 KB |
Output is correct |
8 |
Correct |
88 ms |
8300 KB |
Output is correct |
9 |
Correct |
85 ms |
8300 KB |
Output is correct |
10 |
Incorrect |
88 ms |
8300 KB |
Integer parameter [name=a] equals to -1, violates the range [1, 10^18] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
97 ms |
8300 KB |
Output is correct |
2 |
Correct |
93 ms |
8300 KB |
Output is correct |
3 |
Correct |
96 ms |
8300 KB |
Output is correct |
4 |
Correct |
88 ms |
8300 KB |
Output is correct |
5 |
Correct |
88 ms |
8260 KB |
Output is correct |
6 |
Correct |
88 ms |
8300 KB |
Output is correct |
7 |
Correct |
87 ms |
8300 KB |
Output is correct |
8 |
Correct |
88 ms |
8300 KB |
Output is correct |
9 |
Correct |
85 ms |
8300 KB |
Output is correct |
10 |
Incorrect |
88 ms |
8300 KB |
Integer parameter [name=a] equals to -1, violates the range [1, 10^18] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
8300 KB |
Output is correct |
2 |
Incorrect |
87 ms |
8300 KB |
Integer parameter [name=a] equals to -1, violates the range [1, 10^18] |
3 |
Halted |
0 ms |
0 KB |
- |