Submission #872153

#TimeUsernameProblemLanguageResultExecution timeMemory
872153NotLinuxEuklid (COCI20_euklid)C++17
20 / 110
1036 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define int long long inline int R(int a, int b){ if(a < b)return R(b,a); else if(a >= b and b > 1)return R(a/b,b); else return a; } void solve(){ int g,h; cin >> g >> h; if(g == h)cout << h << " " << h << endl; else if(h == 2)cout << 2*g << " " << g << endl; else if(g == (h*h))cout << h*h << " " << h*h*h << endl; else{ for(int i = 1;i;i++){ if(__gcd(i,h) == 1 and R(i*g,h*g) == h){ cout << i*h << " " << h*g << endl; return; } } } } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int testcase = 1;cin >> testcase; while(testcase--)solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...