친절한 문제다.
long long을 사용하라고 문제에 나와있다.
lcm = A * B / gcd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
/** | |
* https://www.acmicpc.net/problem/13241 | |
* BOJ 백준온라인져지 13241 최소공배수 풀이 | |
*/ | |
int gcd(long long a, long long b){ | |
long long mod = 0; | |
while((mod = a % b)){ | |
a = b; | |
b = mod; | |
} | |
return b; | |
} | |
int main(){ | |
long long result = 0; | |
long long A, B; | |
scanf("%lld%lld", &A, &B); | |
printf("%lld", A * B / gcd(A, B)); | |
} |
'IT > 알고리즘' 카테고리의 다른 글
BOJ 백준온라인져지 2217 로프 풀이 (0) | 2017.12.10 |
---|---|
BOJ 백준온라인져지 1931 회의실배정 풀이 (0) | 2017.12.09 |
BOJ 백준온라인져지 1977 완전제곱수 풀이 (0) | 2017.12.08 |
BOJ 백준온라인져지 10826 피보나치 수 4 풀이 (0) | 2017.12.08 |
BOJ 백준온라인져지 10757 큰 수 A+B 풀이 (0) | 2017.12.08 |