/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Runtime Error 2ms 552.0 KiB
#2 Accepted 37ms 576.0 KiB
#3 Accepted 38ms 596.0 KiB
#4 Accepted 32ms 576.0 KiB
#5 Accepted 28ms 596.0 KiB
#6 Runtime Error 2ms 540.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'

int main()
{   
    
    int t; cin >> t;
    while(t--) {
        int arr[4];
        for (int i = 0; i < 3; i++) {
            cin >> arr[i];
        }
        int diff[4];
        diff[0] = abs(arr[0] - arr[1]);
        diff[1] = abs(arr[1] - arr[2]);
        diff[2] = abs(arr[2] - arr[0]);       
        int cut = 0;
        for (int i = 0; i < 3; i++) {
            cut = __gcd(cut,diff[i]);
        }


        sort(arr+0,arr+3);

        ll ans = 0;
        ans += (arr[1] - arr[0]) / cut;
        ans += (arr[2] - arr[1]) / cut;
        cout << ans << endl;
        
    
    }
    
    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 17:30:38
Judged At
2024-11-11 03:22:54
Judged By
Score
40
Total Time
38ms
Peak Memory
596.0 KiB