We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0696603 commit 0397428Copy full SHA for 0397428
[Week17 - NumberTheory&Prime]/이현동/2436
54.9 KB
[Week17 - NumberTheory&Prime]/이현동/2436.cpp
@@ -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