/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 536.0 KiB
#2 Accepted 7ms 576.0 KiB
#3 Accepted 7ms 616.0 KiB
#4 Accepted 6ms 536.0 KiB
#5 Accepted 5ms 580.0 KiB
#6 Accepted 5ms 576.0 KiB
#7 Accepted 5ms 576.0 KiB
#8 Accepted 4ms 576.0 KiB
#9 Accepted 7ms 572.0 KiB
#10 Accepted 7ms 588.0 KiB

Code

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
 

void solve()
{
    vector<ll>v(3);
    for(auto &c:v)cin>>c;
    sort(all(v));
    ll a=v[1]-v[0];
    ll b=v[2]-v[1];
    ll ct=0;
    if(a==0&&b==0)
    {
        cout<<0<<endl;
        return;
    }
    else if(a==0||b==0)
    {
        cout<<1<<endl;
        return;
    }
    ll g=__gcd(a,b);
    ct=a/g;
    ct+=(b/g);
    cout<<ct<<endl;
 

}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    ll t;cin>>t;
    while(t--)
    {
      solve();
    }    
}

Information

Submit By
Type
Submission
Problem
P1061 Bring equality
Contest
Brain Booster #4
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-14 15:42:10
Judged At
2024-11-11 03:25:37
Judged By
Score
100
Total Time
7ms
Peak Memory
616.0 KiB