/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 532.0 KiB
#2 Wrong Answer 8ms 624.0 KiB
#3 Wrong Answer 6ms 532.0 KiB

Code

#include <bits/stdc++.h>
#define int long long
#define endll '\n';
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;

const int mod = 1e9 + 7, N = 1e6;

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    map<int, int> mp;
    mp[a]++;
    mp[b]++;
    mp[c]++;
    if (mp.size() == 1)
    {
        cout << 0 << endll;
    }
    else if (mp.size() == 2)
    {
        cout << 1 << endll;
    }
    else
    {
        vector<int> v = {a, b, c};
        int lcm = 1;
        int gc = 0;
        sort(all(v));
        for (auto i : v)
        {
            gc = __gcd(i, gc);
            lcm = (lcm * i) / __gcd(lcm, i);
        }

        int ans =1e16;
        int to = v[0] + v[1] + v[2];
        to /= 3;
        ans = min (ans , abs (to - v[0]) + abs (to - v[1]) + abs(to - v[2]) );
        cout << ans << endll;
    }

    // 0 4 8

    //  5 9 14
    // 2
    //  5 10 15
    // 1 2 3
    // 101 1 102
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    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:52
Judged At
2024-11-11 03:25:05
Judged By
Score
10
Total Time
8ms
Peak Memory
624.0 KiB