#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const ld E = 1e-9;
const int N = 5010;
ll h, g;
int mem[N][N][2];
ll R(ll a, ll b){
if (b > a)
return R(b, a);
if (b == 1) return a;
return R(a / b, b);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
for (int i = 1; i <= 5000; i++)
for (int j = i; j <= 5000; j++) {
int fi = __gcd(i, j);
int se = R(i, j);
if (fi >= N || se >= N) continue;
mem[fi][se][0] = i;
mem[fi][se][1] = j;
}
int qq; cin >> qq;
for (; qq; qq--){
cin >> g >> h;
cout << mem[g][h][0] << " " << mem[g][h][1] << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
949 ms |
58788 KB |
Output is correct |
2 |
Execution timed out |
1102 ms |
118924 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
946 ms |
58836 KB |
Output is correct |
2 |
Correct |
959 ms |
58776 KB |
Output is correct |
3 |
Execution timed out |
1108 ms |
118752 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
956 ms |
58852 KB |
Integer parameter [name=a] equals to 0, violates the range [1, 10^18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
942 ms |
58908 KB |
Output is correct |
2 |
Correct |
945 ms |
58808 KB |
Output is correct |
3 |
Correct |
948 ms |
58864 KB |
Output is correct |
4 |
Correct |
946 ms |
58732 KB |
Output is correct |
5 |
Correct |
946 ms |
58836 KB |
Output is correct |
6 |
Correct |
951 ms |
58716 KB |
Output is correct |
7 |
Correct |
947 ms |
58860 KB |
Output is correct |
8 |
Correct |
944 ms |
58732 KB |
Output is correct |
9 |
Correct |
938 ms |
58732 KB |
Output is correct |
10 |
Correct |
938 ms |
58820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
942 ms |
58908 KB |
Output is correct |
2 |
Correct |
945 ms |
58808 KB |
Output is correct |
3 |
Correct |
948 ms |
58864 KB |
Output is correct |
4 |
Correct |
946 ms |
58732 KB |
Output is correct |
5 |
Correct |
946 ms |
58836 KB |
Output is correct |
6 |
Correct |
951 ms |
58716 KB |
Output is correct |
7 |
Correct |
947 ms |
58860 KB |
Output is correct |
8 |
Correct |
944 ms |
58732 KB |
Output is correct |
9 |
Correct |
938 ms |
58732 KB |
Output is correct |
10 |
Correct |
938 ms |
58820 KB |
Output is correct |
11 |
Incorrect |
945 ms |
58840 KB |
Integer parameter [name=a] equals to 0, violates the range [1, 10^18] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
949 ms |
58788 KB |
Output is correct |
2 |
Execution timed out |
1102 ms |
118924 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |