/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 4ms 552.0 KiB
#4 Accepted 4ms 548.0 KiB
#5 Accepted 4ms 532.0 KiB
#6 Accepted 4ms 340.0 KiB
#7 Accepted 4ms 364.0 KiB
#8 Accepted 4ms 548.0 KiB
#9 Accepted 5ms 532.0 KiB
#10 Accepted 5ms 548.0 KiB
#11 Accepted 4ms 332.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

long long sir(long long A, long long B) {
    long long op = 0;

    while (A != 0 && B != 0) {
        if (A > B) {
            op += A / B;
            A %= B;
        } else {
            op += B / A;
            B %= A;
        }
    }

    return op;
}

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

    while (t--) {
        long long A, B;
        cin >> A >> B;

        long long result = sir(A, B);
        cout << result << endl;
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1029 Make it zero
Contest
Brain booster #2
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-06 14:58:48
Judged At
2024-11-11 03:41:46
Judged By
Score
100
Total Time
5ms
Peak Memory
552.0 KiB