Submission
Status:
[PPP-SSSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: Ecir
Problemset: anna
Language: cpp
Time: 0.003 second
Submitted On: 2025-10-04 09:29:43
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
int u=0,v=0;
int ans=0;
void build(int cnt,ll arr[],bool b[],ll w[]){
if(cnt==5){
// for(int i=0;i<=4;i++) cout << w[i] << ' ';
// cout << '\n';
int x,y;
if((w[0]+w[1])&1) return ;
x=(w[0]+w[1])/2;
y=w[0]-x;
if(x>0 && y >0 && x*y==w[2] && x%y==w[3] && x/y==w[4]){
if(ans==0) {
ans++;
u=x,v=y;
}
else if(u!=x || v!=y) ans++;
}
return;
}
for(int i=0;i<=4;i++){
if(b[i]==1) continue;
b[i]=1;
w[cnt]=arr[i];
build(cnt+1,arr,b,w);
b[i]=0;
w[cnt]=0;
}
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int n;cin >> n;
while(n--){
ll arr[10]={};
cin >> arr[0] >> arr[1] >> arr[2] >> arr[3] >> arr[4] ;
bool b[10]={};
ll w[10]={};
u=0,v=0,ans=0;
build(0,arr,b,w);
if(ans==0 || ans>1) cout << 0 << ' ' << 0 << '\n';
else cout << u << ' ' << v << "\n";
}
return 0;
}