Submission

Status:
[PPPP-SSSSSSSSS]

Score: 0

User: Dormon

Problemset: anna

Language: cpp

Time: 0.002 second

Submitted On: 2025-04-12 12:54:30

#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) continue;
        int ta = (v[0] + v[1]) / 2, tb = (v[0] - v[1]) / 2;
        if (ta <= 0 || tb <= 0) continue;
        if (ta * tb == v[2] && ta % tb == v[3] && ta / tb == v[4] && ta > tb){
            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();
    }
}