답안 #374503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
374503 2021-03-07T10:44:39 Z topovik Euklid (COCI20_euklid) C++14
35 / 110
430 ms 9944 KB
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll N = 1e3 + 100;

ll gcd[N][N];

ll f(ll x, ll y)
{
    if (x < y) swap(x, y);
    if (y == 1) return x;
    else return f(x / y, y);
}

int main()
{
    for (ll i = 1; i < N; i++)
        for (ll j = 1; j < N; j++) gcd[i][j] = __gcd(i, j);
    ll t;
    cin >> t;
    while (t--)
    {
        ll x, y;
        cin >> x >> y;
        if (x == y)
        {
            cout << x << " " << x << endl;
            continue;
        }
        if (y == 2)
        {
            cout << x << " " << 2 * x << endl;
            continue;
        }
        if (x == y * y)
        {
            cout << x << " " << x * y << endl;
            continue;
        }
        ll l = -1, r = -1;
        for (ll i = 1; i < N; i++)
            for (ll j = 1; j < N; j++)
              if (gcd[i][j] == 1 && f(i * x, j * x) == y) {l = i * x, r = j * x;break;}
        cout << l << " " << r << endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 9836 KB Output is correct
2 Correct 52 ms 9836 KB Output is correct
3 Correct 52 ms 9836 KB Output is correct
4 Correct 52 ms 9836 KB Output is correct
5 Correct 52 ms 9836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 9836 KB Output is correct
2 Correct 53 ms 9836 KB Output is correct
3 Correct 52 ms 9836 KB Output is correct
4 Correct 52 ms 9836 KB Output is correct
5 Correct 52 ms 9836 KB Output is correct
6 Correct 52 ms 9836 KB Output is correct
7 Correct 52 ms 9836 KB Output is correct
8 Correct 52 ms 9836 KB Output is correct
9 Correct 52 ms 9836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 9836 KB Output is correct
2 Correct 52 ms 9836 KB Output is correct
3 Correct 52 ms 9836 KB Output is correct
4 Correct 52 ms 9836 KB Output is correct
5 Correct 53 ms 9836 KB Output is correct
6 Correct 52 ms 9836 KB Output is correct
7 Correct 52 ms 9836 KB Output is correct
8 Correct 52 ms 9836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 401 ms 9836 KB Output is correct
2 Correct 430 ms 9836 KB Output is correct
3 Correct 411 ms 9836 KB Output is correct
4 Correct 389 ms 9944 KB Output is correct
5 Correct 381 ms 9836 KB Output is correct
6 Correct 380 ms 9836 KB Output is correct
7 Correct 390 ms 9836 KB Output is correct
8 Correct 398 ms 9836 KB Output is correct
9 Correct 414 ms 9836 KB Output is correct
10 Correct 415 ms 9836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 401 ms 9836 KB Output is correct
2 Correct 430 ms 9836 KB Output is correct
3 Correct 411 ms 9836 KB Output is correct
4 Correct 389 ms 9944 KB Output is correct
5 Correct 381 ms 9836 KB Output is correct
6 Correct 380 ms 9836 KB Output is correct
7 Correct 390 ms 9836 KB Output is correct
8 Correct 398 ms 9836 KB Output is correct
9 Correct 414 ms 9836 KB Output is correct
10 Correct 415 ms 9836 KB Output is correct
11 Incorrect 289 ms 9836 KB Integer parameter [name=a] equals to -1, violates the range [1, 10^18]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 9836 KB Output is correct
2 Correct 52 ms 9836 KB Output is correct
3 Correct 52 ms 9836 KB Output is correct
4 Correct 52 ms 9836 KB Output is correct
5 Correct 52 ms 9836 KB Output is correct
6 Correct 65 ms 9836 KB Output is correct
7 Correct 53 ms 9836 KB Output is correct
8 Correct 52 ms 9836 KB Output is correct
9 Correct 52 ms 9836 KB Output is correct
10 Correct 52 ms 9836 KB Output is correct
11 Correct 52 ms 9836 KB Output is correct
12 Correct 52 ms 9836 KB Output is correct
13 Correct 52 ms 9836 KB Output is correct
14 Correct 52 ms 9836 KB Output is correct
15 Correct 52 ms 9836 KB Output is correct
16 Correct 52 ms 9836 KB Output is correct
17 Correct 52 ms 9836 KB Output is correct
18 Correct 52 ms 9836 KB Output is correct
19 Correct 53 ms 9836 KB Output is correct
20 Correct 52 ms 9836 KB Output is correct
21 Correct 52 ms 9836 KB Output is correct
22 Correct 52 ms 9836 KB Output is correct
23 Correct 401 ms 9836 KB Output is correct
24 Correct 430 ms 9836 KB Output is correct
25 Correct 411 ms 9836 KB Output is correct
26 Correct 389 ms 9944 KB Output is correct
27 Correct 381 ms 9836 KB Output is correct
28 Correct 380 ms 9836 KB Output is correct
29 Correct 390 ms 9836 KB Output is correct
30 Correct 398 ms 9836 KB Output is correct
31 Correct 414 ms 9836 KB Output is correct
32 Correct 415 ms 9836 KB Output is correct
33 Incorrect 289 ms 9836 KB Integer parameter [name=a] equals to -1, violates the range [1, 10^18]
34 Halted 0 ms 0 KB -