Submission #854483

# Submission time Handle Problem Language Result Execution time Memory
854483 2023-09-27T18:07:54 Z vjudge1 Euklid (COCI20_euklid) C++17
15 / 110
1000 ms 452 KB
//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int calc(int a, int b) {
    while(a != 1) {
        //cerr << a << " " << b << "\n";
        if(b < a) {
            swap(a, b);
            continue;
        }

        int _a = a;
        a = b / a;
        b = _a;
    }

    return b;
}

#define ONLINE_JUDGE
void solve() {
    int a, b;
    cin >> a >> b;

    for(int l = 1; l <= 2500; l++) {
        for(int r = l; r <= 2500; r++) {
            if(__gcd(l, r) == a && calc(l, r) == b) {
                return cout << l << " " << r << "\n", void();
            }
        }
    }
    
    return;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen(".in", "r", stdin);
        freopen(".out", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t = 1; cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 37 ms 348 KB Output is correct
2 Execution timed out 1027 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 424 KB Output is correct
2 Correct 270 ms 348 KB Output is correct
3 Execution timed out 1024 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 348 KB Output is correct
2 Correct 19 ms 452 KB Output is correct
3 Correct 20 ms 448 KB Output is correct
4 Correct 22 ms 448 KB Output is correct
5 Correct 25 ms 344 KB Output is correct
6 Correct 30 ms 344 KB Output is correct
7 Correct 36 ms 344 KB Output is correct
8 Correct 44 ms 344 KB Output is correct
9 Correct 50 ms 348 KB Output is correct
10 Correct 62 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 348 KB Output is correct
2 Correct 19 ms 452 KB Output is correct
3 Correct 20 ms 448 KB Output is correct
4 Correct 22 ms 448 KB Output is correct
5 Correct 25 ms 344 KB Output is correct
6 Correct 30 ms 344 KB Output is correct
7 Correct 36 ms 344 KB Output is correct
8 Correct 44 ms 344 KB Output is correct
9 Correct 50 ms 348 KB Output is correct
10 Correct 62 ms 348 KB Output is correct
11 Incorrect 869 ms 424 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 348 KB Output is correct
2 Execution timed out 1027 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -