Submission #854472

#TimeUsernameProblemLanguageResultExecution timeMemory
854472vjudge1Euklid (COCI20_euklid)C++17
35 / 110
5 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define sp << " " << #define int long long #define vi vector<int> #define pb push_back #define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++) #define pii pair<int,int> int f(int a,int b) { if (a < b) swap(a,b); if (b == 1) return a; return f(a/b,b); } void solve() { int g,h; cin >> g >> h; if (g == h) { cout << g sp g << endl; return; } if (h == 2) { cout << g sp 2*g << endl; return; } if (g == h*h) { cout << h*h*h sp h*h << endl; return; } else if (max(g,h) <= 20) { for (int i=1;i<=2000;i++) { for (int j=1;j<=2000;j++) { if (f(g*i,g*j) == h && __gcd(i,j) == 1) { cout << g*i sp g*j << endl; return; } } } } } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t = 1; cin >> t; while (t --> 0) 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...