This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define sz(a) (int)a.size()
#define ll long long
#define int long long
#define ld long double
const int N = 3e5 + 100;
int f(int a, int b)
{
if(a < b)
{
return f(b, a);
}
if(b == 1)
{
return a;
}
return f(a / b, b);
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while(t--)
{
int g, h;
cin >> g >> h;
int a1, b1;
for(int a = 1; a <= 500; a++)
{
for(int b = 1; b <= 500; b++)
{
if(__gcd(a, b) == g &&f(a, b) == h)
{
a1 = a;
b1= b;
}
}
}
cout << a1 << " " << b1 << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |