Submission #489672

#TimeUsernameProblemLanguageResultExecution timeMemory
489672fuad27Euklid (COCI20_euklid)C++17
35 / 110
15 ms292 KiB
#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 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...