/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 10ms 596.0 KiB
#3 Accepted 9ms 608.0 KiB
#4 Accepted 9ms 584.0 KiB
#5 Accepted 8ms 608.0 KiB
#6 Accepted 7ms 584.0 KiB
#7 Accepted 8ms 576.0 KiB
#8 Accepted 7ms 580.0 KiB
#9 Accepted 9ms 772.0 KiB
#10 Accepted 10ms 632.0 KiB

Code

/*who_knows_*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T, typename R> using omap = tree<T, R, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = 1e18 + 10;
const int N = 1e6 + 10;

void solve() {
    vector<int>v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(all(v));
    int d1 = v[1] - v[0], d2 = v[2] - v[1];
    int g = __gcd(d1, d2);
    if (g == 0) cout << 0 << endl;
    else cout << d1 / g + d2 / g << endl;
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int t = 1, cs = 1;
    cin >> t;
    while (t--) {
        // cout << "Case " << cs++ << ": ";
        solve();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1061 Bring equality
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-15 05:41:38
Judged At
2024-10-03 13:32:05
Judged By
Score
100
Total Time
10ms
Peak Memory
772.0 KiB