/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 6ms 584.0 KiB
#3 Accepted 6ms 612.0 KiB
#4 Accepted 6ms 580.0 KiB
#5 Accepted 5ms 604.0 KiB
#6 Accepted 4ms 572.0 KiB
#7 Accepted 4ms 560.0 KiB
#8 Accepted 4ms 584.0 KiB
#9 Accepted 7ms 576.0 KiB
#10 Accepted 6ms 580.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-10-03 13:35:45
Judged By
Score
100
Total Time
7ms
Peak Memory
612.0 KiB