Submission #328128

#TimeUsernameProblemLanguageResultExecution timeMemory
328128hhhhauraEuklid (COCI20_euklid)C++14
110 / 110
1 ms384 KiB
#include <bits/stdc++.h> #pragma loop-opt(on) #pragma GCC optmize("Ofast") #define print(x) cout << #x <<" = " << x << endl #define pprint(x) cout << #x <<" = (" << x.first << " , " << x.second <<" )\n" #define rep(i, a, b) for(int i = a; i <= b; i++) #define rrep(i, a, b) for(int i = b; i >= a; i--) #define ceil(a, b) ((a + b - 1) / b) #define all(x) x.begin(), x.end() #define MAXN 1000005 #define INF 1000000000000000000 #define MOD 1000000007 #define eps (1e-9) #define int long long int #define lld long double #define pii pair<int, int> #define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()) using namespace std; int t, g, h, a, b, hh; bool check(int a, int b) { int aa = a, bb = b; if(__gcd(a, b) != g) return false; while(b != 1) { if(a < b) swap(a, b); else a /= b; pprint(pii(a, b)); } pprint(pii(aa, bb)); if(a != h) pprint(pii(h, g)); return a == h; } void solve(int g, int h) { hh = h; while(hh <= g) hh *= h; b = g * ceil(hh, g), a = b * h + g; } signed main() { ios::sync_with_stdio(false), cin.tie(0); // rep(i, 1, 1500) rep(j, 2, 1500) g = i, h = j, solve(i, j),pprint(pii(a, b)),assert(check(a, b)); cin >> t; while(t--) { cin >> g >> h, hh = h; while(hh <= g) hh *= h; b = g * ceil(hh, g), a = b * h + g; cout << a <<" " << b <<"\n"; // print(check(a, b)); } return 0; }

Compilation message (stderr)

euklid.cpp:2: warning: ignoring #pragma loop  [-Wunknown-pragmas]
    2 | #pragma loop-opt(on)
      | 
euklid.cpp:3: warning: ignoring #pragma GCC optmize [-Wunknown-pragmas]
    3 | #pragma GCC optmize("Ofast")
      |
#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...