Submission

Status:

[PPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: KantaponZ

Problemset: anna

Language: cpp

Time: 0.003 second

Submitted On: 2025-08-24 13:52:30

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

#define ll long long

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int N;
    cin >> N;
    while (N--) {
        vector<ll> v(5);
        for (int i = 0; i < 5; i++) cin >> v[i];
        int cnt = 0;
        ll ans1, ans2;
        sort(v.begin(), v.end());
        do {
            if ((v[0] + v[1]) % 2 || (v[0] - v[1]) % 2) continue;
            ll A = (v[0] + v[1]) / 2; ll B = v[0] - A;
            if (!(A > B && B > 0)) continue;
            if (A * B != v[2]) continue;
            if (A / B != v[3]) continue;
            if (A % B != v[4]) continue;
            ans1 = A, ans2 = B;
            cnt++;
        } while (next_permutation(v.begin(), v.end()));
        if (cnt != 1) cout << "0 0\n";
        else cout << ans1 << " " << ans2 << "\n";
    }
}