Accepted
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