답안 #473914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
473914 2021-09-16T11:51:28 Z Ahmed57 Euklid (COCI20_euklid) C++14
15 / 110
1000 ms 35536 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;
        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 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 35532 KB Output is correct
2 Execution timed out 1082 ms 35532 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 35532 KB Output is correct
2 Correct 458 ms 35516 KB Output is correct
3 Execution timed out 1092 ms 35432 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 35532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 35532 KB Output is correct
2 Correct 43 ms 35536 KB Output is correct
3 Correct 46 ms 35432 KB Output is correct
4 Correct 50 ms 35532 KB Output is correct
5 Correct 52 ms 35524 KB Output is correct
6 Correct 62 ms 35532 KB Output is correct
7 Correct 71 ms 35460 KB Output is correct
8 Correct 81 ms 35452 KB Output is correct
9 Correct 96 ms 35504 KB Output is correct
10 Correct 114 ms 35480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 35532 KB Output is correct
2 Correct 43 ms 35536 KB Output is correct
3 Correct 46 ms 35432 KB Output is correct
4 Correct 50 ms 35532 KB Output is correct
5 Correct 52 ms 35524 KB Output is correct
6 Correct 62 ms 35532 KB Output is correct
7 Correct 71 ms 35460 KB Output is correct
8 Correct 81 ms 35452 KB Output is correct
9 Correct 96 ms 35504 KB Output is correct
10 Correct 114 ms 35480 KB Output is correct
11 Execution timed out 1090 ms 35516 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 35532 KB Output is correct
2 Execution timed out 1082 ms 35532 KB Time limit exceeded
3 Halted 0 ms 0 KB -