Submission #854461

# Submission time Handle Problem Language Result Execution time Memory
854461 2023-09-27T17:09:28 Z vjudge1 Euklid (COCI20_euklid) C++17
35 / 110
1000 ms 600 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define lim 100000
using namespace std;
const int mod=1000000007ll;

int res(int i,int j){
    if(i<j)return res(j,i);
    if(j==1)return i;
    return res(i/j,j);
}

void solve(){
    int g,h;
    cin>>g>>h;
    if(g==h){
        cout<<g<<" "<<g<<"\n";
    }else if(h==2){
        cout<<g*2<<" "<<g<<"\n";
    }else if(g==h*h){
        cout<<h*h*h<<" "<<h*h<<"\n";
    }else{
        for(int i=1;1;i++){
            for(int j=1;j<=i;j++){
                if(__gcd(i,j)==g&&res(i,j)==h){
                    cout<<i<<" "<<j<<"\n";
                    return;
                }
            }
        }
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
    freopen("in","r",stdin);
    freopen("out","w",stdout);
#endif
    int t=1;
    cin>>t;
    while (t--)
    {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 456 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 600 KB Output is correct
2 Correct 16 ms 460 KB Output is correct
3 Correct 21 ms 344 KB Output is correct
4 Correct 27 ms 348 KB Output is correct
5 Correct 26 ms 344 KB Output is correct
6 Correct 36 ms 348 KB Output is correct
7 Correct 47 ms 348 KB Output is correct
8 Correct 59 ms 348 KB Output is correct
9 Correct 69 ms 440 KB Output is correct
10 Correct 85 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 600 KB Output is correct
2 Correct 16 ms 460 KB Output is correct
3 Correct 21 ms 344 KB Output is correct
4 Correct 27 ms 348 KB Output is correct
5 Correct 26 ms 344 KB Output is correct
6 Correct 36 ms 348 KB Output is correct
7 Correct 47 ms 348 KB Output is correct
8 Correct 59 ms 348 KB Output is correct
9 Correct 69 ms 440 KB Output is correct
10 Correct 85 ms 348 KB Output is correct
11 Execution timed out 1084 ms 344 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 0 ms 348 KB Output is correct
7 Correct 0 ms 360 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 456 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 456 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 6 ms 600 KB Output is correct
24 Correct 16 ms 460 KB Output is correct
25 Correct 21 ms 344 KB Output is correct
26 Correct 27 ms 348 KB Output is correct
27 Correct 26 ms 344 KB Output is correct
28 Correct 36 ms 348 KB Output is correct
29 Correct 47 ms 348 KB Output is correct
30 Correct 59 ms 348 KB Output is correct
31 Correct 69 ms 440 KB Output is correct
32 Correct 85 ms 348 KB Output is correct
33 Execution timed out 1084 ms 344 KB Time limit exceeded
34 Halted 0 ms 0 KB -