Accepted
Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
int main()
{
int t; cin >> t;
while(t--) {
int arr[4];
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
int diff[4];
diff[0] = abs(arr[0] - arr[1]);
diff[1] = abs(arr[1] - arr[2]);
diff[2] = abs(arr[2] - arr[0]);
int cut = 0;
for (int i = 0; i < 3; i++) {
cut = __gcd(cut,diff[i]);
}
if (cut == 0) cout << 0 << endl;
else{
sort(arr+0,arr+3);
ll ans = 0;
ans += (arr[1] - arr[0]) / cut;
ans += (arr[2] - arr[1]) / cut;
cout << ans << endl;
}
}
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 17:58:45
- Judged At
- 2024-11-11 03:22:32
- Judged By
- Score
- 100
- Total Time
- 29ms
- Peak Memory
- 604.0 KiB