Submission #374324

#TimeUsernameProblemLanguageResultExecution timeMemory
374324VEGAnnEuklid (COCI20_euklid)C++14
0 / 110
1039 ms492 KiB
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; const ld E = 1e-9; const int N = 1010; ll h, g; ll R(ll a, ll b){ if (b > a) return R(b, a); if (b == 1) return a; return R(a / b, b); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL int qq; cin >> qq; for (; qq; qq--){ cin >> g >> h; bool was = 0; for (int i = 1; i <= 1000 && !was; i++) for (int j = 1; j <= 1000 && !was; j++) if (__gcd(i, j) == g && R(i, j) == h){ cout << i << " " << j; was = 1; break; } // for (ll i = g; ; i += g){ // for (ll i = 1; ; i++){ // if (R(i, g) == h){ // cout << g << " " << i << '\n'; // break; // } // } } return 0; }
#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...