Submission #872264

#TimeUsernameProblemLanguageResultExecution timeMemory
872264NotLinuxEuklid (COCI20_euklid)C++17
110 / 110
1 ms600 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; } int g,h; void solve(){ cin >> g >> h; int l = h , r = 2 * h - 1; while(true){ if((l + (g - l%g)) <= r){ int k = (l + (g - l%g)) / g; if(R(g*k,g*k*h+g) == h){ cout << g * k << " " << g * k * h + g << endl; return; } } l *= h; r *= h; } } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int testcase;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...