답안 #374392

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
374392 2021-03-07T09:05:59 Z VEGAnn Euklid (COCI20_euklid) C++14
4 / 110
1000 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const ld E = 1e-9;
const int N = 2010;
ll h, g;

ll R(ll a, ll b){
    if (b > a)
        return R(b, a);

    if (b == 1) return a;

    return R(a / b, b);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    int qq; cin >> qq;

    for (; qq; qq--){
        cin >> g >> h;

        ll beg = g * ((h + g - 1) / g);

        for (ll i = 1; ; i++)
            if (__gcd(beg, i) == g && R(i, beg) == h){
                cout << beg << " " << i << '\n';
                break;
            }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 218 ms 388 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 242 ms 492 KB Output is correct
5 Correct 153 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Execution timed out 1095 ms 364 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 512 KB Output is correct
2 Execution timed out 1097 ms 364 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Execution timed out 1087 ms 364 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Execution timed out 1087 ms 364 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 218 ms 388 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 242 ms 492 KB Output is correct
5 Correct 153 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Execution timed out 1095 ms 364 KB Time limit exceeded
9 Halted 0 ms 0 KB -