blob: 62e779903b1e98467e521780307a390afcd49176 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <iostream>
long long gcd(int a, int b)
{
long long d, r;
if ((a == b) || (a == 0))
return a;
if (b == 0)
return b;
if (b > a) {
d = a;
a = b;
b = d;
}
for(;;) {
d = a / b;
r = a - (d * b);
if (r == 0)
break;
a = b;
b = r;
}
return (long long) b;
}
long long lcm(int a, int b)
{
return (b / gcd(a, b)) * a;
}
int main() {
int a, b;
std::cin >> a >> b;
std::cout << lcm(a, b) << std::endl;
return 0;
}
|