/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 340.0 KiB
#3 Accepted 2ms 540.0 KiB
#4 Accepted 3ms 488.0 KiB
#5 Accepted 3ms 540.0 KiB
#6 Accepted 3ms 540.0 KiB
#7 Accepted 3ms 540.0 KiB
#8 Accepted 3ms 540.0 KiB
#9 Accepted 4ms 540.0 KiB
#10 Accepted 4ms 548.0 KiB
#11 Accepted 3ms 540.0 KiB

Code

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

int main() {
    int tc;
    cin >> tc;
    while(tc--)
    {
        long long a,b;
        cin >> a >> b;
        long long op=0;
        while(a!=0 && b!=0)
        {
            long long mx = max(a,b);
            long long mn = min(a,b);
            op += mx/mn;
            mx %= mn;
            a = mx;
            b = mn;
        }
        cout << op << endl;
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1029 Make it zero
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-04 08:53:01
Judged At
2024-03-04 15:27:02
Judged By
Score
100
Total Time
4ms
Peak Memory
548.0 KiB