[백준] 2609 최대공약수와 최소공배수

0

백준

목록 보기
213/271
post-thumbnail
post-custom-banner

[백준] 2609 최대공약수와 최소공배수

#include <algorithm>
#include <math.h>
#include <iostream>
using namespace std;

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int a, b;
	cin >> a >> b;

	if (a < b) swap(a, b);

	int g = gcd(a, b);
	int l = a * b / g;

	cout << g << "\n" << l;
	return 0;
}
profile
Be able to be vulnerable, in search of truth

0개의 댓글