이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
if(b==0) return a;
return gcd(b,a%b);
}
int R(int a,int b){
if(b>a) swap(a,b);
if(b==1) return a;
if(a==1) return b;
return R(a/b,b);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t--){
int g,h;
cin>>g>>h;
if(g==h){
cout<<g<<" "<<h<<endl;
continue;
}
bool sw=0;
for(int i=1;i<=10000;i++){
for(int j=1;j<=10000;j++){
if(R(i,j)==h && g==gcd(i,j)){
cout<<i<<" "<<j<<endl;
sw=1;
break;
}
}
if(sw) 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... |