Submission
Status:
[PPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: ki
Problemset: anna
Language: cpp
Time: 0.003 second
Submitted On: 2026-03-20 23:15:35
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll=long long;
int q;
int main(){
cin>>q;
while(q--){
bool ok=0;
vector<ll>c(5);
for(auto&e:c)cin>>e;
sort(c.rbegin(),c.rend());
vector<pair<int,int>>ans;
for(int i=0;i<5;i++){
for(int j=i+1;j<5;j++){
if(i==j)continue;
ll x=(c[i]+c[j])/2,y=(c[i]-c[j])/2;
if(x*2!=c[i]+c[j]||y*2!=c[i]-c[j]||y<=0||x<=y)continue;
vector<ll>w{x+y,x-y,x*y,x%y,x/y};
sort(w.rbegin(),w.rend());
if(w==c)ans.emplace_back(x,y);
}
}
sort(ans.begin(),ans.end());
ans.resize(unique(ans.begin(),ans.end())-ans.begin());
if(ans.size()!=1)cout<<0<<' '<<0<<'\n';
else cout<<ans[0].first<<' '<<ans[0].second<<'\n';
}
}