Submission
Status:
[PPP-SSSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: Seng
Problemset: anna
Language: cpp
Time: 0.002 second
Submitted On: 2026-06-27 11:33:27
#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++){
int x;cin >> x;
v.push_back(x);
}
ll n1, n2;
string ans = "";
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);
}
}while(next_permutation(v.begin(), v.end()));
if(ans == "") cout << "0 0" << '\n';
else if(ans.size() > 3) cout << "0 0" << '\n';
else cout << ans << '\n';
}
}