답안 #854484

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854484 2023-09-27T18:09:36 Z vjudge1 Euklid (COCI20_euklid) C++17
35 / 110
1000 ms 452 KB
//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int i64

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, int b) {
    cout << a << " ";
    for(int i = a; ; i += a) {
        if(calc(i, a) == b) {
            return cout << i << "\n", void();
        }
    }
    
    return;
}

void solve2(int a, int 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++) {
        int a, b;
        cin >> a >> b;

        if(max(a, b) <= 20) {
            solve2(a, b);
        } else {
            solve(a, b);
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 348 KB Output is correct
2 Correct 19 ms 348 KB Output is correct
3 Correct 20 ms 452 KB Output is correct
4 Correct 25 ms 348 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 43 ms 348 KB Output is correct
9 Correct 50 ms 344 KB Output is correct
10 Correct 62 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 348 KB Output is correct
2 Correct 19 ms 348 KB Output is correct
3 Correct 20 ms 452 KB Output is correct
4 Correct 25 ms 348 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 43 ms 348 KB Output is correct
9 Correct 50 ms 344 KB Output is correct
10 Correct 62 ms 348 KB Output is correct
11 Execution timed out 1049 ms 348 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 11 ms 348 KB Output is correct
24 Correct 19 ms 348 KB Output is correct
25 Correct 20 ms 452 KB Output is correct
26 Correct 25 ms 348 KB Output is correct
27 Correct 25 ms 344 KB Output is correct
28 Correct 30 ms 344 KB Output is correct
29 Correct 36 ms 344 KB Output is correct
30 Correct 43 ms 348 KB Output is correct
31 Correct 50 ms 344 KB Output is correct
32 Correct 62 ms 348 KB Output is correct
33 Execution timed out 1049 ms 348 KB Time limit exceeded
34 Halted 0 ms 0 KB -