#include <stdio.h> #include <iostream> #include <algorithm> #include <map> #include <string> #include <vector> #include <queue> using namespace std; int A, B; // 유클리드 호제법 int gcd(int a, int b) { if(b == 0) { return a; } else { return gcd(b, a%b); } } int main(void) { // freopen("B10430_input.txt", "r", stdin); cin >> A >> B; int GCD = gcd(A, B); int LCD = A * B / GCD; cout << GCD << endl; cout << LCD << endl; return 0; } | cs |
'Baekjoon > Math' 카테고리의 다른 글
[백준 1212] 8진수 2진수 (Math) (C/C++) (0) | 2020.01.24 |
---|---|
[백준 1373] 2진수 8진수 (Math) (C/C++) (0) | 2020.01.24 |
[백준 11005] 진법 변환2 (Math) (C/C++) (0) | 2020.01.24 |
[백준 2745] 진법 변환 (Math) (C/C++) (0) | 2020.01.24 |
[백준 9613] GCD 합 (Math) (C/C++) (0) | 2020.01.24 |