Accepted
Code
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void Solve()
{
ll arr[3];
for (ll i = 0; i < 3; i++)
cin >> arr[i];
sort(arr, arr + 3);
ll d1 = arr[1] - arr[0], d2 = arr[2] - arr[1];
ll k = __gcd(d1, d2);
if (k == 0) {
cout << "0\n";
} else {
cout << (d1 / k) + (d2 / k) << "\n";
}
}
int32_t main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while (t--)
Solve();
return 0;
}
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 17:52:23
- Judged At
- 2024-11-11 03:22:39
- Judged By
- Score
- 100
- Total Time
- 7ms
- Peak Memory
- 616.0 KiB