/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 14ms 604.0 KiB
#3 Accepted 13ms 540.0 KiB
#4 Accepted 13ms 572.0 KiB
#5 Accepted 12ms 540.0 KiB
#6 Accepted 12ms 540.0 KiB
#7 Accepted 12ms 540.0 KiB
#8 Accepted 13ms 832.0 KiB
#9 Accepted 13ms 540.0 KiB
#10 Accepted 13ms 540.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define neg cout << -1 << endl
#define pb push_back
#define ss second
#define ff first

const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int INF = 1e18;
int md = 998244353;

void solve()
{
    int n = 3;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int f = a[1] - a[0], s = a[2] - a[1];
    int ab = gcd(f, s);
    if(ab==0)
    {
        cout<<0<<endl;
        return;
    }


    int cnt = (f / ab) + (s / ab);
    cout << cnt << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int test = 1;
    cin >> test;
    for (int tc = 0; tc < test; tc++)
    {
        solve();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1061 Bring equality
Language
C++17 (G++ 13.2.0)
Submit At
2024-07-14 20:06:40
Judged At
2024-07-14 20:06:40
Judged By
Score
100
Total Time
14ms
Peak Memory
832.0 KiB