Submission #473918

# Submission time Handle Problem Language Result Execution time Memory
473918 2021-09-16T11:54:28 Z Ahmed57 Euklid (COCI20_euklid) C++14
35 / 110
1000 ms 35660 KB
#include <bits/stdc++.h>
using namespace std;
int dp[3001][3001];
long long r(long long a,long long b){
    if(dp[a][b]!=-1)return dp[a][b];
    if(a<b)return dp[a][b]= r(b,a);
    else if(a>=b&&b>1)return dp[a][b]=r(abs(a/b),b);
    else if(a>=b&&b==1)return dp[a][b]=a;
}
int main(){
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    memset(dp,-1,sizeof dp);
    int t;cin>>t;
    z:while(t--){
        long long a,b;
        cin>>a>>b;
        if(a==b||b==2||a==b*b){
            cout<<a*b<<" "<<a<<"\n";goto z;
        }
        for(int i = 1;i<=3000;i++){
            for(int j = 1;j<=3000;j++){
                if(__gcd(i,j)==a&&r(i,j)==b){
                    cout<<i<<" "<<j<<"\n";
                    goto z;
                }
            }
        }
    }
    return 0;
}

Compilation message

euklid.cpp: In function 'long long int r(long long int, long long int)':
euklid.cpp:9:1: warning: control reaches end of non-void function [-Wreturn-type]
    9 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35532 KB Output is correct
2 Correct 16 ms 35532 KB Output is correct
3 Correct 15 ms 35440 KB Output is correct
4 Correct 16 ms 35532 KB Output is correct
5 Correct 16 ms 35436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35472 KB Output is correct
2 Correct 15 ms 35532 KB Output is correct
3 Correct 17 ms 35528 KB Output is correct
4 Correct 16 ms 35512 KB Output is correct
5 Correct 16 ms 35428 KB Output is correct
6 Correct 19 ms 35464 KB Output is correct
7 Correct 19 ms 35444 KB Output is correct
8 Correct 16 ms 35532 KB Output is correct
9 Correct 16 ms 35532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 35428 KB Output is correct
2 Correct 15 ms 35464 KB Output is correct
3 Correct 16 ms 35532 KB Output is correct
4 Correct 17 ms 35532 KB Output is correct
5 Correct 16 ms 35444 KB Output is correct
6 Correct 19 ms 35660 KB Output is correct
7 Correct 19 ms 35532 KB Output is correct
8 Correct 19 ms 35536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 35532 KB Output is correct
2 Correct 41 ms 35532 KB Output is correct
3 Correct 45 ms 35532 KB Output is correct
4 Correct 47 ms 35532 KB Output is correct
5 Correct 50 ms 35472 KB Output is correct
6 Correct 60 ms 35532 KB Output is correct
7 Correct 68 ms 35532 KB Output is correct
8 Correct 76 ms 35456 KB Output is correct
9 Correct 87 ms 35432 KB Output is correct
10 Correct 107 ms 35528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 35532 KB Output is correct
2 Correct 41 ms 35532 KB Output is correct
3 Correct 45 ms 35532 KB Output is correct
4 Correct 47 ms 35532 KB Output is correct
5 Correct 50 ms 35472 KB Output is correct
6 Correct 60 ms 35532 KB Output is correct
7 Correct 68 ms 35532 KB Output is correct
8 Correct 76 ms 35456 KB Output is correct
9 Correct 87 ms 35432 KB Output is correct
10 Correct 107 ms 35528 KB Output is correct
11 Execution timed out 1097 ms 35532 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35532 KB Output is correct
2 Correct 16 ms 35532 KB Output is correct
3 Correct 15 ms 35440 KB Output is correct
4 Correct 16 ms 35532 KB Output is correct
5 Correct 16 ms 35436 KB Output is correct
6 Correct 16 ms 35472 KB Output is correct
7 Correct 15 ms 35532 KB Output is correct
8 Correct 17 ms 35528 KB Output is correct
9 Correct 16 ms 35512 KB Output is correct
10 Correct 16 ms 35428 KB Output is correct
11 Correct 19 ms 35464 KB Output is correct
12 Correct 19 ms 35444 KB Output is correct
13 Correct 16 ms 35532 KB Output is correct
14 Correct 16 ms 35532 KB Output is correct
15 Correct 15 ms 35428 KB Output is correct
16 Correct 15 ms 35464 KB Output is correct
17 Correct 16 ms 35532 KB Output is correct
18 Correct 17 ms 35532 KB Output is correct
19 Correct 16 ms 35444 KB Output is correct
20 Correct 19 ms 35660 KB Output is correct
21 Correct 19 ms 35532 KB Output is correct
22 Correct 19 ms 35536 KB Output is correct
23 Correct 28 ms 35532 KB Output is correct
24 Correct 41 ms 35532 KB Output is correct
25 Correct 45 ms 35532 KB Output is correct
26 Correct 47 ms 35532 KB Output is correct
27 Correct 50 ms 35472 KB Output is correct
28 Correct 60 ms 35532 KB Output is correct
29 Correct 68 ms 35532 KB Output is correct
30 Correct 76 ms 35456 KB Output is correct
31 Correct 87 ms 35432 KB Output is correct
32 Correct 107 ms 35528 KB Output is correct
33 Execution timed out 1097 ms 35532 KB Time limit exceeded
34 Halted 0 ms 0 KB -