Submission
Status:
[PPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: nigger123
Problemset: anna
Language: cpp
Time: 0.002 second
Submitted On: 2025-10-10 10:19:35
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
while (n--) {
vector<ll> input(5);
for (int i = 0; i < 5; ++i)
cin >> input[i];
sort(input.begin(), input.end());
int solutions = 0;
ll finalX = 0, finalY = 0;
do {
ll sum = input[0]; // x + y
ll diff = input[1]; // x - y
ll prod = input[2]; // x * y
ll div = input[3]; // x / y
ll mod = input[4]; // x % y
if ((sum + diff) % 2 != 0 || (sum - diff) % 2 != 0)
continue;
ll x = (sum + diff) / 2;
ll y = (sum - diff) / 2;
if (x <= 0 || y <= 0 || x <= y) continue;
// verify
if (x + y != sum) continue;
if (x - y != diff) continue;
if (x * y != prod) continue;
if (x / y != div) continue;
if (x % y != mod) continue;
// check if this is the only solutoin
++solutions;
finalX = x;
finalY = y;
} while (next_permutation(input.begin(), input.end()));
if (solutions == 1)
cout << finalX << " " << finalY << "\n";
else
cout << "0 0\n";
}
return 0;
}