/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Runtime Error 2ms 560.0 KiB
#2 Accepted 6ms 576.0 KiB
#3 Accepted 6ms 580.0 KiB
#4 Accepted 5ms 576.0 KiB
#5 Accepted 5ms 616.0 KiB
#6 Runtime Error 1ms 576.0 KiB

Code

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

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

int32_t main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int t; cin >> t;
    while(t--) {
        int arr[3];
        for (int i = 0; i < 3; i++) {
            cin >> arr[i];
        }
        int diff[3];
        diff[0] = abs(arr[0] - arr[1]);
        diff[1] = abs(arr[1] - arr[2]);
        diff[2] = abs(arr[2] - arr[0]);       
        int gcdd = 0;
        for (int i = 0; i < 3;i++) {
            gcdd = __gcd(gcdd,diff[i]);
        }


        sort(arr+0,arr+3);

        ll ans = 0;
        ans += (arr[1] - arr[0]) / gcdd;
        ans += (arr[2] - arr[1]) / gcdd;
        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:26:50
Judged At
2024-11-11 03:22:59
Judged By
Score
40
Total Time
6ms
Peak Memory
616.0 KiB