알고리즘

C++ 알고리즘 - 백준 1934 최소공배수

마루설아 2025. 1. 11. 23:12

https://www.acmicpc.net/problem/1934

 

#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

void CPP_INIT() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main(void) {
	CPP_INIT();

	int input;
	int num1, num2;

	cin >> input;
	for (int i = 0; i < input; i++) {
		cin >> num1 >> num2;
		int n1 = num1, n2 = num2;

		while (num1 != num2) {
			if (num1 > num2) num2 += n2;
			else num1 += n1;
		}

		cout << num1 << endl;
	}
}