Submission
Status:
[PPP-SSSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: Seng
Problemset: anna
Language: cpp
Time: 0.003 second
Submitted On: 2026-06-27 11:38:11
#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> v;
for(int i = 0; i < 5; i++){
ll x;cin >> x;
v.push_back(x);
}
ll n1, n2;
string ans = "";
int cnt = 0;
sort(v.begin(), v.end());
do{
n1 = (v[0]+v[1])/2;
n2 = (v[0]-v[1])/2;
if(n1 < n2 || (v[0]+v[1])%2 != 0 || (v[0]-v[1])%2 != 0 || n1 <= 0 || n2 <= 0) continue;
if(n2 != 0 && n1*n2 == v[2] && n1/n2 == v[3] && n1%n2 == v[4]){
ans += to_string(n1) + " " + to_string(n2);
cnt++;
}
}while(next_permutation(v.begin(), v.end()));
if(cnt == 0) cout << "0 0" << '\n';
else if(cnt > 1) cout << "0 0" << '\n';
else cout << ans << '\n';
}
}