-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13241_LCM.cpp
More file actions
52 lines (41 loc) · 806 Bytes
/
13241_LCM.cpp
File metadata and controls
52 lines (41 loc) · 806 Bytes
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
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
int main()
{
//static int TC = 0;
static int itr = 0;
static unsigned long long int inputA = 0;
static unsigned long long int inputB = 0;
static unsigned long long int a = 0;
static unsigned long long int b = 0;
static unsigned long long int tmp = 0;
static unsigned long long int r = 0;
static unsigned long long int GCD = 0;
static unsigned long long int LCM = 0;
//std::cin >> TC;
//for (itr = 0; itr < TC; itr++)
{
a = b = tmp = r = GCD = LCM = 0;
std::cin >> inputA;
std::cin >> inputB;
a = inputA;
b = inputB;
if (b > a)
{
tmp = a;
a = b;
b = tmp;
}
// get GCD and LCM
while (b != 0)
{
r = a % b;
a = b;
b = r;
}
GCD = a;
//LCM
LCM = (inputA * inputB) / GCD;
std::cout << LCM << std::endl;
}
return 0;
}