Accepted
Code
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int t;
cin >> t;
while (t--){
vector<int> a(3);
cin >> a[0] >> a[1] >> a[2];
int ans = 0, g = 0;
sort(a.begin(), a.end());
g = __gcd(g, a[1] - a[0]);
g = __gcd(g, a[2] - a[1]);
if (!g){
cout << 0 << endl;
continue;
}
ans += (a[1] - a[0]) / g;
ans += (a[2] - a[1]) / g;
cout << ans << endl;
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1061 Bring equality
- Contest
- Brain Booster #4
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-07-14 15:46:53
- Judged At
- 2024-11-11 03:25:28
- Judged By
- Score
- 100
- Total Time
- 31ms
- Peak Memory
- 608.0 KiB