#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()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for(I i=2;i<=2700;i++)
for(I j=2;j<=3200;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;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
775 ms |
2500 KB |
Output is correct |
2 |
Correct |
766 ms |
2500 KB |
Output is correct |
3 |
Correct |
782 ms |
2544 KB |
Output is correct |
4 |
Correct |
781 ms |
2532 KB |
Output is correct |
5 |
Correct |
781 ms |
2500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
781 ms |
2588 KB |
Output is correct |
2 |
Correct |
796 ms |
2616 KB |
Output is correct |
3 |
Correct |
783 ms |
2600 KB |
Output is correct |
4 |
Correct |
778 ms |
2488 KB |
Output is correct |
5 |
Correct |
771 ms |
2588 KB |
Output is correct |
6 |
Correct |
777 ms |
2452 KB |
Output is correct |
7 |
Correct |
776 ms |
2432 KB |
Output is correct |
8 |
Correct |
782 ms |
2540 KB |
Output is correct |
9 |
Correct |
788 ms |
2548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
788 ms |
2520 KB |
Output is correct |
2 |
Correct |
783 ms |
2512 KB |
Output is correct |
3 |
Correct |
787 ms |
2448 KB |
Output is correct |
4 |
Correct |
784 ms |
2752 KB |
Output is correct |
5 |
Correct |
787 ms |
2676 KB |
Output is correct |
6 |
Correct |
772 ms |
2488 KB |
Output is correct |
7 |
Correct |
790 ms |
2456 KB |
Output is correct |
8 |
Correct |
783 ms |
2636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
792 ms |
2416 KB |
Output is correct |
2 |
Correct |
777 ms |
2488 KB |
Output is correct |
3 |
Incorrect |
784 ms |
2512 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
792 ms |
2416 KB |
Output is correct |
2 |
Correct |
777 ms |
2488 KB |
Output is correct |
3 |
Incorrect |
784 ms |
2512 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
775 ms |
2500 KB |
Output is correct |
2 |
Correct |
766 ms |
2500 KB |
Output is correct |
3 |
Correct |
782 ms |
2544 KB |
Output is correct |
4 |
Correct |
781 ms |
2532 KB |
Output is correct |
5 |
Correct |
781 ms |
2500 KB |
Output is correct |
6 |
Correct |
781 ms |
2588 KB |
Output is correct |
7 |
Correct |
796 ms |
2616 KB |
Output is correct |
8 |
Correct |
783 ms |
2600 KB |
Output is correct |
9 |
Correct |
778 ms |
2488 KB |
Output is correct |
10 |
Correct |
771 ms |
2588 KB |
Output is correct |
11 |
Correct |
777 ms |
2452 KB |
Output is correct |
12 |
Correct |
776 ms |
2432 KB |
Output is correct |
13 |
Correct |
782 ms |
2540 KB |
Output is correct |
14 |
Correct |
788 ms |
2548 KB |
Output is correct |
15 |
Correct |
788 ms |
2520 KB |
Output is correct |
16 |
Correct |
783 ms |
2512 KB |
Output is correct |
17 |
Correct |
787 ms |
2448 KB |
Output is correct |
18 |
Correct |
784 ms |
2752 KB |
Output is correct |
19 |
Correct |
787 ms |
2676 KB |
Output is correct |
20 |
Correct |
772 ms |
2488 KB |
Output is correct |
21 |
Correct |
790 ms |
2456 KB |
Output is correct |
22 |
Correct |
783 ms |
2636 KB |
Output is correct |
23 |
Correct |
792 ms |
2416 KB |
Output is correct |
24 |
Correct |
777 ms |
2488 KB |
Output is correct |
25 |
Incorrect |
784 ms |
2512 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |