Submission #473947

# Submission time Handle Problem Language Result Execution time Memory
473947 2021-09-16T12:43:23 Z BidoTeima Euklid (COCI20_euklid) C++17
15 / 110
1000 ms 63200 KB
/// isA AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ACPLS()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define tc         \
    int tttttt,subtask;    \
    cin >> tttttt /*>> subtask*/; \
    while (tttttt--)
#define sumrange(l, r, arr) (l == 0 ? arr[r] : arr[r] - arr[l - 1])
#define all(v) v.begin(), v.end()
ll GCDAC(ll a, ll b)
{
    if(b==0)
        return a;
 
    return GCDAC(b, a%b);
}
ll gcd(ll a, ll b)
{
    if(a<b)swap(a,b);
    return GCDAC(a, b);
}
int dp[(int)4005][(int)4005];
int R(int a, int b){
    if(dp[a][b]!=-1)
        return dp[a][b];
    if(a<b)
        return dp[a][b]=R(b,a);
    if(a>=b&&b>1)
        return dp[a][b]=R(a/b,b);
    return dp[a][b]=a;
}
int main()
{
    ACPLS();
    memset(dp,-1,sizeof(dp));
tc{
    int g,h;
    cin>>g>>h;
    for(int a = 1; a <= 4000; a++){
        bool flag=0;
        for(int b = 1; b <= 4000; b++){
            if(gcd(a,b)==g&&R(a,b)==h){
                cout<<a<<' '<<b<<'\n';
                flag=1;
                break;
            }
        }
        if(flag)break;
    }
}
}

Compilation message

euklid.cpp: In function 'int main()':
euklid.cpp:12:16: warning: unused variable 'subtask' [-Wunused-variable]
   12 |     int tttttt,subtask;    \
      |                ^~~~~~~
euklid.cpp:43:1: note: in expansion of macro 'tc'
   43 | tc{
      | ^~
# Verdict Execution time Memory Grader output
1 Correct 111 ms 63052 KB Output is correct
2 Execution timed out 1078 ms 62984 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 107 ms 63200 KB Output is correct
2 Correct 600 ms 63064 KB Output is correct
3 Execution timed out 1081 ms 63052 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 63032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 46 ms 63052 KB Output is correct
2 Correct 62 ms 63064 KB Output is correct
3 Correct 70 ms 63068 KB Output is correct
4 Correct 82 ms 63012 KB Output is correct
5 Correct 81 ms 63052 KB Output is correct
6 Correct 90 ms 63068 KB Output is correct
7 Correct 103 ms 63012 KB Output is correct
8 Correct 119 ms 63064 KB Output is correct
9 Correct 128 ms 63064 KB Output is correct
10 Correct 163 ms 63068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 63052 KB Output is correct
2 Correct 62 ms 63064 KB Output is correct
3 Correct 70 ms 63068 KB Output is correct
4 Correct 82 ms 63012 KB Output is correct
5 Correct 81 ms 63052 KB Output is correct
6 Correct 90 ms 63068 KB Output is correct
7 Correct 103 ms 63012 KB Output is correct
8 Correct 119 ms 63064 KB Output is correct
9 Correct 128 ms 63064 KB Output is correct
10 Correct 163 ms 63068 KB Output is correct
11 Execution timed out 1081 ms 63036 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 111 ms 63052 KB Output is correct
2 Execution timed out 1078 ms 62984 KB Time limit exceeded
3 Halted 0 ms 0 KB -