Submission #872226

#TimeUsernameProblemLanguageResultExecution timeMemory
872226NotLinuxEuklid (COCI20_euklid)C++17
35 / 110
240 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 2000; inline int rand(int l, int r){ static mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int> ludo(l, r); return ludo(rng); } 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<=N;i++){ for(int j = i+1;j<=N;j++){ if(__gcd(i,j) == 1 and R(i*g,j*g) == h){ cout << i*g << " " << j*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...