/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 6ms 604.0 KiB
#3 Accepted 6ms 604.0 KiB
#4 Accepted 5ms 576.0 KiB
#5 Accepted 5ms 536.0 KiB
#6 Accepted 4ms 532.0 KiB
#7 Accepted 4ms 372.0 KiB
#8 Accepted 4ms 580.0 KiB
#9 Accepted 5ms 620.0 KiB
#10 Accepted 5ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ps(b) cout << (b ? "YES" : "NO") << '\n'
#define pc cout << "Case " << tc << ": "
#ifdef LOCAL
#include "def.h"
#else
#define ck(...) 
#endif
const ll M = 1e9 + 7, N = 2e5 + 5;

void test(int tc) {
    ll a = 0, b = 0, c = 0, d = 0, i = 0, j = 0, k = 0, m = 0, n = 0, q = 0;
    // cin >> n;
    vector<ll> v(3); for (i = 0; i < 3; ++i) { cin >> v[i]; }
    sort(v.begin(), v.end());
    if(v[0] == v[2])
        cout << 0;
    else if(v[0] == v[1] or v[1] == v[2])
        cout << 1;
    else {
        a = gcd(v[1] - v[0], v[2] - v[1]);
        cout << (v[1] - v[0]) / a + (v[2] - v[1]) / a;
    }
    cout << '\n';
}

signed main() {
    cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit|cin.badbit);
    int tc = 0, t = 1;
    cin >> t;
    while (tc < t) test(++tc);
    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 16:19:58
Judged At
2024-10-03 13:37:57
Judged By
Score
100
Total Time
6ms
Peak Memory
620.0 KiB