int getLCM(int A, int B) { int mulA = A; int mulB = B; int mulLeast = A * B; int ReturnValue; while (true) { if ((mulLeast > mulA) && (mulLeast > mulB)) { if (mulA < mulB) mulA += A; else if (mulA == mulB) { ReturnValue = mulA; break; } else mulB += B; } else { ReturnValue = mulLeast; break; } } return ReturnValue; } int getGCD(int A, int B) { int ReturnValue; for(int i = 1; i <= (A < B ? A : B); i++) { if(A % i == 0 && B % i == 0 ) ReturnValue = i; } return ReturnValue; }
<소스 코드>
*Source of the problem = https://www.acmicpc.net/problem/2609
*문제 출처 : BAEKJOON ONLINE JUDGE
댓글
댓글 쓰기