본문 바로가기

Coding/BaekJoon

B_1934

#include <iostream>

using namespace std;

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

int main(void)
{
    int T, A, B, temp, answer;
    cin >> T;
    for (int i = 0; i < T; i++)
    {
        cin >> A >> B;
        if (A >= B)
            temp = gcd(A, B);
        else
            temp = gcd(B, A);
        answer = A * B / temp;
        cout << answer << endl;
    }
}

'Coding > BaekJoon' 카테고리의 다른 글

B_4948  (0) 2023.11.27
B_10816  (0) 2023.11.18
B_11478  (0) 2023.11.17
B_1620  (0) 2023.11.17
B_7785  (0) 2023.11.17