/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 540.0 KiB
#3 Wrong Answer 1ms 540.0 KiB

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
Submission
Problem
P1025 GCM
Contest
Brain booster #2
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-06 13:34:34
Judged At
2024-11-11 03:42:31
Judged By
Score
2
Total Time
1ms
Peak Memory
540.0 KiB