이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define iter(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp make_pair
#define F first
#define S second
#define lsort(a) sort(iter(a))
#define eb emplace_back
#define gsort(a) sort(iter(a), greater<>());
using namespace std;
typedef long long ll;
ll R(ll a, ll b){
while(b > 1){
if(a < b) swap(a, b);
a /= b;
//cerr << a << " " << b << "\n";
}
return a;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T--){
ll g, h;
cin >> g >> h;
ll a = -1, b = -1;
if(g == h){
a = b = g;
}
else if(h == 2){
a = g * 2;
b = g;
}
else if(g == h * h){
a = g * h;
b = g;
}
else{
for(ll i = 1; i <= 1000; i++){
for(ll j = 1; j <= 1000; j++){
if(__gcd(i, j) == g && R(i, j) == h){
a = i, b = j;
goto ok;
}
}
}
}
ok:;
//assert(__gcd(a, b) == g && R(a, b) == h);
cout << a << " " << b << "\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... |