이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#ifndef Local
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define lim 100000
using namespace std;
const int mod=1000000007ll;
int res(int i,int j){
if(i<j)return res(j,i);
if(j==1)return i;
return res(i/j,j);
}
void solve(){
int g,h;
cin>>g>>h;
if(g==h){
cout<<g<<" "<<g<<"\n";
}else if(h==2){
cout<<g*2<<" "<<g<<"\n";
}else if(g==h*h){
cout<<h*h*h<<" "<<h*h<<"\n";
}else{
for(int i=1;1;i++){
for(int j=1;j<=i;j++){
if(__gcd(i,j)==1&&res(i*g,j*g)==h){
cout<<i<<" "<<j<<"\n";
return;
}
}
}
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
int t=1;
cin>>t;
while (t--)
{
solve();
}
}
# | 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... |