/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 22ms 620.0 KiB
#3 Wrong Answer 23ms 584.0 KiB

Code

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

#define ll long long
#define pb push_back
#define fast ios::sync_with_stdio(false);cin.tie(nullptr)

ll gcd(ll a, ll b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
}

ll lcm(ll a, ll b) { 
    return a / gcd(a, b) * b; 
}

string toupper(string a) { 
    for (int i = 0; i < (int)a.size(); ++i) 
        if (a[i] >= 'a' && a[i] <= 'z') 
            a[i] -= 32; 
    return a; 
}

string tolower(string a) { 
    for (int i = 0; i < (int)a.size(); ++i) 
        if (a[i] >= 'A' && a[i] <= 'Z') 
            a[i] += 32; 
    return a; 
}

bool prime(ll a) { 
    if (a == 1) 
        return false; 
    for (int i = 2; i <= round(sqrt(a)); ++i) 
        if (a % i == 0) 
            return false; 
    return true; 
}

constexpr long long pow(long long a, long long b) {
    long long res = 1;
    for (; b; b /= 2, a *= a) {
        if (b % 2)
            res *= a;
    }
    return res;
}

constexpr int factorial(int k) {
    int res = 1;
    for (int i = 2; i <= k; i++)
        res *= i;
    return res;
}

bool check() {
    return true;
}

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) return (a.second > b.second);
    return (a.first < b.first);
}

bool check(int a, int b, int c) {
    if ( a== b && b == c && a == c) {
        return true;
    }
    else return false;
}

int main () {
    fast;
    int tc;
    cin >> tc;
    while (tc--) {
        vector <int> v(3);
        for (int i=0; i<3; i++) {
            cin >> v[i];
        }
        sort (v.begin(), v.end());

        if (v[0] == v[1] && v[1] == v[2]) {
            cout << 0 << endl;
        }
        else if (v[0] == v[1] || v[1] == v[2] || v[0] == v[2]) {
            cout << 1 << endl;
        }
        else {
            int val1 = abs(v[0] - v[1]);
            int val2 = abs(v[1] - v[2]);
            int mini = min(val1, val2);

            if (mini == val1) {
                if (val2%mini == 0) {
                    cout << 1 + val2/val1 << endl; 
                }
                else {
                    cout << val1 + val2 << endl;
                }
            }
            else if (mini == val2) {
                if (val1%mini == 0) {
                    cout << 1 + val1/val2 << endl; 
                }
                else {
                    cout << val1 + val2 << 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 16:38:55
Judged At
2024-11-11 03:23:52
Judged By
Score
10
Total Time
23ms
Peak Memory
620.0 KiB