/ SeriousOJ /

Record Detail

Accepted


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

Code

#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int t; cin >> t;
    while(t--){
        int a, b, c; cin >> a >> b >> c;
        vector<int> vect = {a, b, c};
        sort(vect.begin(), vect.end());
        int diff1 = vect[1] - vect[0];
        int diff2 = vect[2] - vect[1];
        if (diff1 == 0 && diff2 == 0) {
            cout << 0 << '\n';
            continue;
        }
        int k = __gcd(diff1, diff2);
        if (k == 0) {
            cout << -1 << '\n';
            continue;
        }
        int cnt = (diff1 / k) + (diff2 / k);
        cout << cnt << '\n';
    }
    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 15:58:54
Judged At
2024-11-11 03:25:03
Judged By
Score
100
Total Time
6ms
Peak Memory
616.0 KiB