Submission
Status:
[PPP-SSSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: KantaponZ
Problemset: anna
Language: cpp
Time: 0.002 second
Submitted On: 2025-08-24 13:21:29
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool check(ll A, ll B, multiset<ll> ms) {
if (A < B) swap(A, B);
auto it1 = ms.find(A - B);
if (it1 == ms.end()) return false;
else ms.erase(it1);
auto it2 = ms.find(A/B);
if (it2 == ms.end()) return false;
else ms.erase(it2);
auto it3 = ms.find(A % B);
if (it3 == ms.end()) return false;
else ms.erase(it3);
return true;
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int N;
cin >> N;
while (N--) {
multiset<ll> ms;
for (int i = 0; i < 5; i++) {
ll x; cin >> x;
ms.insert(x);
}
ll fs, sc;
auto it = prev(ms.end());
fs = *it;
it = prev(it);
sc = *it;
ms.erase(prev(ms.end())), ms.erase(prev(ms.end()));
if (fs - sc == 1) {
if (check(sc, 1, ms)) {
cout << sc << " " << 1 << "\n";
} else {
cout << 0 << " " << 0 << "\n";
}
continue;
}
if (sc * sc < 4 * fs) {
cout << 0 << " " << 0 << "\n";
continue;
}
double A1, A2;
A1 = (sc + sqrt(sc * sc - 4 * fs)) / 2;
A2 = (sc - sqrt(sc * sc - 4 * fs)) / 2;
if (A1 != floor(A1) && A2 != floor(A2)) {
cout << 0 << " " << 0 << "\n";
continue;
}
ll A;
if (A1 == floor(A1)) {
A = A1;
}
if (A2 == floor(A2)) {
A = A2;
}
ll B = sc - A;
if (B < 1) {
cout << 0 << " " << 0 << "\n";
continue;
}
//cout << A << " " << B << " ";
if (check(A, B, ms)) {
cout << max(A, B) << " " << min(A, B) << "\n";
continue;
}
cout << "0 0\n";
}
}