/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 30ms 580.0 KiB
#3 Accepted 31ms 584.0 KiB
#4 Accepted 29ms 560.0 KiB
#5 Accepted 28ms 564.0 KiB
#6 Accepted 29ms 556.0 KiB
#7 Accepted 30ms 544.0 KiB
#8 Accepted 28ms 560.0 KiB
#9 Accepted 30ms 608.0 KiB
#10 Accepted 30ms 592.0 KiB

Code

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

int main(){
  int t;
  cin >> t;
  while (t--){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    int ans = 0, g = 0;
    sort(a.begin(), a.end());
    g = __gcd(g, a[1] - a[0]);
    g = __gcd(g, a[2] - a[1]);
    if (!g){
      cout << 0 << endl;
      continue;
    }
    ans += (a[1] - a[0]) / g;
    ans += (a[2] - a[1]) / g;
    cout << ans << endl;
  }
}

Information

Submit By
Type
Submission
Problem
P1061 Bring equality
Contest
Brain Booster #4
Language
C++17 (G++ 13.2.0)
Submit At
2024-07-14 15:46:53
Judged At
2024-11-11 03:25:28
Judged By
Score
100
Total Time
31ms
Peak Memory
608.0 KiB