/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 532.0 KiB
#2 Accepted 7ms 564.0 KiB
#3 Accepted 6ms 616.0 KiB
#4 Accepted 6ms 616.0 KiB
#5 Accepted 5ms 576.0 KiB
#6 Accepted 4ms 572.0 KiB
#7 Accepted 4ms 584.0 KiB
#8 Accepted 4ms 580.0 KiB
#9 Accepted 7ms 596.0 KiB
#10 Accepted 7ms 536.0 KiB

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