/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 6ms 612.0 KiB
#3 Accepted 7ms 608.0 KiB
#4 Accepted 6ms 608.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 632.0 KiB
#10 Accepted 7ms 604.0 KiB

Code

#include <bits/stdc++.h> 
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef vector<ll> v64;
typedef vector<p64> vp64;
ll mod = 1e9+7;
const ll N = 500005;
double eps = 1e-12;
ll dr[] = {1,-1,0,0};
ll dc[] = {0,0,1,-1};
#define forn(i,e) for(ll i = 0; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define pb push_back
#define fi first
#define se second
#define nn "\n"
#define inf 2e18
#define setbit(x,k) (x|= (1LL<<k))
#define checkbit(x,k) ((x>>k)&1)
#define clearbit(x,k) (x&= ~(1LL<<k))
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


void solve(ll t){
    ll n,m,temp,ans=0,i,j,k,a,b,c,u,v;
    v64 vv(3);
    forn(i,3) cin>>vv[i];
    sort(all(vv));
    if(vv[0]==vv[2]) cout << 0 << nn;
    else if(vv[0]==vv[1] || vv[1]==vv[2]) cout << 1 << nn;
    else{
        a = vv[1]-vv[0];
        b = vv[2]-vv[1];
        c = gcd(a,b);
        cout << (a/c) + (b/c) << nn;
    }
    
}
int main()
{
    fast_cin();
    ll t = 1;
    cin >> t;
    for(int it=1;it<=t;it++) {
        solve(it);
    }
    return 0;
}

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:48:17
Judged At
2024-10-03 13:39:09
Judged By
Score
100
Total Time
7ms
Peak Memory
632.0 KiB