#include <bits/stdc++.h>
using namespace std;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll R(ll a, ll b) {
if (a<b) swap(a,b);
if (b==1) return a;
return R(a/b, b);
}
void solve1(ll g, ll h) {
assert(g==h);
cout<<g<<" "<<g*g<<"\n";
}
void solve2(ll g, ll h) {
assert(h==2);
cout<<2*g<<" "<<g<<"\n";
}
void solve(ll g, ll h) {
for (int x=1; x<=1000; x++) {
for (int y=1; y<=1000; y++) {
if (__gcd(x,y)==g && R(x,y)==h) {
cout<<x<<" "<<y<<"\n";
return;
}
}
}
assert(false);
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int t;
cin>>t;
while (t--) {
ll g,h;
cin>>g>>h;
if (g==h) {
solve1(g,h);
} else if (h==2) {
solve2(g,h);
} else {
solve(g,h);
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
52 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
364 KB |
Output is correct |
2 |
Correct |
9 ms |
364 KB |
Output is correct |
3 |
Correct |
10 ms |
396 KB |
Output is correct |
4 |
Correct |
11 ms |
364 KB |
Output is correct |
5 |
Correct |
12 ms |
364 KB |
Output is correct |
6 |
Correct |
15 ms |
364 KB |
Output is correct |
7 |
Correct |
17 ms |
364 KB |
Output is correct |
8 |
Correct |
21 ms |
492 KB |
Output is correct |
9 |
Correct |
24 ms |
396 KB |
Output is correct |
10 |
Runtime error |
59 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
364 KB |
Output is correct |
2 |
Correct |
9 ms |
364 KB |
Output is correct |
3 |
Correct |
10 ms |
396 KB |
Output is correct |
4 |
Correct |
11 ms |
364 KB |
Output is correct |
5 |
Correct |
12 ms |
364 KB |
Output is correct |
6 |
Correct |
15 ms |
364 KB |
Output is correct |
7 |
Correct |
17 ms |
364 KB |
Output is correct |
8 |
Correct |
21 ms |
492 KB |
Output is correct |
9 |
Correct |
24 ms |
396 KB |
Output is correct |
10 |
Runtime error |
59 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Runtime error |
52 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
16 |
Halted |
0 ms |
0 KB |
- |