Submission #524288

# Submission time Handle Problem Language Result Execution time Memory
524288 2022-02-09T02:16:52 Z theVPN Euklid (COCI20_euklid) C++17
0 / 110
1000 ms 3088 KB
#include <bits/stdc++.h>
#define TASK C
#define I int
#define ll long long
#define ld long double
#define ull unsigned ll
#define nl '\n'
#define debug(a,n) \
for (I i=1;i<=(n);i++) \
    cout<<(a)[i]<<" "; \
cout<<nl;
#define idebug(a,n) \
for (I i=n;i>=1;i--) \
    cout<<(a)[i]<<" "; \
cout<<nl;
#define debug2(a,n) \
for (I i=1;i<=(n);i++) \
    cout<<(a)[i].first<<" <<(a)[i].second<<nl;
#define idebug2(a,n) \
for (I i=n;i>=1;i--) \
    cout<<(a)[i].first<<" <<(a)[i].second<<nl;
using namespace std;
const I vpn=1e6;
I t;
ll a,b,g,h;
map<pair<ll,ll>,pair<ll,ll>> nho;
ll edicul(ll a,ll b)
{
    if (a<b)
        return edicul(b,a);
    if (b>1)
        return edicul(a/b,b);
    return a;
}
void DeoACLamCho()
{
    cin>>g>>h;
    if (g==h)
    {
        cout<<g<<" "<<h<<nl;
        return;
    }
    if (h==2)
    {
        cout<<g<<" "<<2*g<<nl;
        return;
    }
    if (g==h*h)
    {
        cout<<g<<" "<<g*h<<nl;
        return;
    }
    if (g>h)
    {
        cout<<g<<" "<<g*h<<nl;
        return;
    }
    cout<<nho[{g,h}].first<<" "<<nho[{g,h}].second<<nl;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    for(I i=2;i<=3500;i++)
        for(I j=2;j<=3500;j++)
            if (nho[{__gcd(i,j),edicul(i,j)}].first==0)
                nho[{__gcd(i,j),edicul(i,j)}]={i,j};
    cin>>t;
    while(t--)
        DeoACLamCho();
}

Compilation message

euklid.cpp:18:25: warning: missing terminating " character
   18 |     cout<<(a)[i].first<<" <<(a)[i].second<<nl;
      |                         ^
euklid.cpp:21:25: warning: missing terminating " character
   21 |     cout<<(a)[i].first<<" <<(a)[i].second<<nl;
      |                         ^
euklid.cpp: In function 'int main()':
euklid.cpp:63:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |     freopen("input.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
euklid.cpp:64:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |     freopen("output.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1100 ms 3008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 2960 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 3088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 2972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 2972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1100 ms 3008 KB Time limit exceeded
2 Halted 0 ms 0 KB -