Submission

Status:

[PPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: mantaggez

Problemset: anna

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-20 21:34:10

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

ll t, n = 5;
ll num[6];

void solve()
{
    for(ll i=1;i<=n;i++) cin >> num[i];
    sort(num + 1, num + n + 1);
    
    set<pii> ans;
    for(ll i=1;i<=n;i++) {
        for(ll j=1;j<=n;j++) {
            if(i == j) continue;
            ll S = num[i];
            ll D = num[j];
            if((S + D) % 2 == 0 && (S - D) % 2 == 0) {
                ll a = (S + D) / 2;
                ll b = (S - D) / 2;
                if(a > b && b > 0) {
                    vector<ll> comp = {a + b, a - b, a * b, a % b, a / b};
                    sort(comp.begin(), comp.end());
                    bool match = true;
                    for(int k=1;k<=n;k++) {
                        if(num[k] != comp[k - 1])
                            match = false;
                    }
                    if(match) ans.insert({a, b});
                }
            }
        }
    }

    if(ans.size() == 1) {
        auto [a, b] = *ans.begin();
        cout << a << ' ' << b << '\n';
    }
    else cout << 0 << ' ' << 0 << '\n';
    
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> t;
    while(t--) {
        solve();
    }

    return 0;
}