I made a program for codechef and its wrong apparantly (although all tests have been positive). The code is:
     #include <iostream>
using namespace std;
int g (int a,int b){
    return b == 0 ? a : g(b, a % b);
}
int l (int a, int b){
    return (a*b)/(g(a,b));
}
int main() {
    int n;
    cin >> n;
    int a[n],b[n];
    for (int x = 0;x<n;x++){
        cin >> a[x] >> b[x];    
    }
    for (int x = 0;x<n;x++){
        cout << g(a[x],b[x]) << " "<< l(a[x],b[x]) << endl;
    }
    return 0;
}
Codechef won't tell me what integers dont work, and im pretty sure my gcd function is legit.
Aucun commentaire:
Enregistrer un commentaire