이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int r(int a, int b) {
if(a < b)return r(b, a);
if(b > 1)return r(a/b, b);
return a;
}
int main () {
int t;
cin >> t;
while(t--) {
int g, h;
cin >> g >> h;
if(g == h) {
cout << g << ' ' << g << endl;
}
else if(h == 2 or g == h*h) {
cout << h*g << ' ' << g << endl;
}
else {
bool check = false;
for(int a = g;a<=10000;a+=g) {
for(int b = g;b<=10000;b+=g) {
if(r(a, b) == h and __gcd(a, b) == g) {
cout << a << ' ' << b << endl;
check = true;
break;
}
}
if(check)break;
}
}
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |