Submission #872152

#TimeUsernameProblemLanguageResultExecution timeMemory
872152SalihSahinEuklid (COCI20_euklid)C++14
15 / 110
15 ms600 KiB
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define int long long using namespace std; const int N = 2e5 + 5; const int mod = 1e9+7; const int inf = 1e18 + 10; const int L = 20 * 20 * 20; int gcd(int a, int b){ if(a < b) swap(a, b); if(b == 0) return a; return gcd(b, a%b); } int r(int a, int b){ if(a < b) swap(a, b); if(b == 1) return a; return r(a/b, b); } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); int t; cin>>t; while(t--){ int g, h; cin>>g>>h; int a, b; a = -1, b = -1; for(int i = g; i <= L; i += g){ for(int j = i; j <= L; j += g){ if(gcd(i, j) == g && r(i, j) == h){ a = i, b = j; break; } } if(a > 0) break; } cout<<a<<" "<<b<<endl; } 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...