【題解】ZeroJudge d256: 11388 – GCD LCM

【題目敘述】https://zerojudge.tw/ShowProblem?problemid=d256

#include <iostream>
using namespace std;

int main() {
    int T, G, L;
    cin >> T;
    while (T--){
        cin >> G >> L;
        if (L % G != 0){
            cout << "-1\n";
            continue;
        }
        cout << G << ' ' << L << '\n';
    }
    return 0;
}
分享本文 Share with friends