Skip to content

Commit 0397428

Browse files
committed
공약수
1 parent 0696603 commit 0397428

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
54.9 KB
Binary file not shown.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
typedef long long ll;
4+
5+
ll A, B;
6+
ll gcd(ll x, ll y)
7+
{
8+
return y ? gcd(y, x % y) : x;
9+
}
10+
11+
int main()
12+
{
13+
ios::sync_with_stdio(0);
14+
cin.tie(0);
15+
16+
cin >> A >> B;
17+
18+
ll r = B / A;
19+
pair<ll, ll> res;
20+
for (int i = 1; i <= sqrt(r); i++)
21+
{
22+
if(r % i == 0){
23+
ll a = i, b = r / i;
24+
if(gcd(a, b) == 1){
25+
res = {a, b};
26+
}
27+
}
28+
}
29+
cout << res.first * A << ' ' << res.second * A;
30+
return 0;
31+
}

0 commit comments

Comments
 (0)