/ SeriousOJ /

Record Detail

Accepted


  

Code

#include <iostream>
using namespace std;

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

long long int lcm(long long int a, long long int b) {
    return (a / gcd(a, b)) * b;
}

long long int find_gcm(long long int a, long long int b, long long int c, long long int X) {
    long long int gcm_ab = lcm(a, b);
    long long int gcm_abc = lcm(gcm_ab, c);

    if (gcm_abc < X) {
        return gcm_abc;
    } else {
        return -1;
    }
}

int main() {
    int T;
    cin >> T;

    while (T--) {
        long long int a, b, c, X;
        cin >> a >> b >> c >> X;

        long long int result = find_gcm(a, b, c, X);

        cout << result << endl;
    }

    return 0;
}

Information

Submit By
Type
Pretest
Problem
P1025 GCM
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-06 13:38:42
Judged At
2024-11-11 03:42:16
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes