Submission

Status:
[PPPP-SSSSSSSSS]

Score: 0

User: Dormon

Problemset: anna

Language: cpp

Time: 0.003 second

Submitted On: 2025-04-12 13:11:58

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

void solve(){
    vector<int> v(5, 0);
    for (auto &e:v)
        cin >> e;
    sort(v.begin(), v.end());
    int a = 0, b = 0, cnt = 0;
    do {
        if ((v[0] + v[1]) % 2 == 1 || v[0] <= v[1]) continue;
        int ta = (v[0] + v[1]) / 2, tb = v[0] - ta;
        if (tb <= 0 || ta <= tb) continue;
        if ((ta * tb) == v[2] && (ta % tb) == v[3] && (ta / tb) == v[4]){
            a = ta, b = tb;
            cnt++;
        }
    } while (next_permutation(v.begin(), v.end()));
    if (cnt == 1)
        cout << a << ' ' << b << '\n';
    else
        cout << "0 0\n";
}

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

    int q;
    cin >> q;
    while (q--){
        solve();
    }
}