/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 592.0 KiB
#2 Accepted 1ms 444.0 KiB
#3 Accepted 2ms 540.0 KiB
#4 Accepted 2ms 284.0 KiB
#5 Accepted 2ms 540.0 KiB
#6 Accepted 3ms 320.0 KiB
#7 Accepted 3ms 540.0 KiB
#8 Accepted 3ms 540.0 KiB
#9 Accepted 3ms 540.0 KiB
#10 Accepted 3ms 540.0 KiB
#11 Accepted 3ms 552.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
///ofstream file("output0.txt");
void solve()
{
    ll a,b; cin>>a>>b;
    ll ans=0;
    while(a>0 && b>0)
    {
        ll mx=max(a,b);
        ll mn=min(a,b);
        ll x = mx/mn;
        ans += x;
        a = mn;
        b = mx-(x*mn);
    }
    cout<<ans<<endl;
    //file<<ans<<endl;
}
int main(){
    int t; cin>>t; while(t--) solve();
//file.close();
}

Information

Submit By
Type
Submission
Problem
P1029 Make it zero
Language
C++20 (G++ 13.2.0)
Submit At
2024-01-30 19:43:39
Judged At
2024-01-30 19:43:39
Judged By
Score
100
Total Time
3ms
Peak Memory
592.0 KiB