Submission

Status:

[PPP-SSSSSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: kimza

Problemset: anna

Language: cpp

Time: 0.003 second

Submitted On: 2026-03-05 21:19:56

#include <bits/stdc++.h>
#define int long long
using namespace std;
void check(){
    vector<int> s;
    int v,w,x,y,z;
    cin >> v >> w >> x >> y >> z;
    s.push_back(v);
    s.push_back(w);
    s.push_back(x);
    s.push_back(y);
    s.push_back(z);
    sort(s.begin(),s.end(),greater<int>());
    int a=0,b=0;
    if(s[0]-s[1]!=1){
        //find a,b
        double b1 = (s[1]+sqrt((s[1]*s[1])-(4*s[0])))/2;
        double b2 = (s[1]-sqrt((s[1]*s[1])-(4*s[0])))/2;
        if(sqrt((s[1]*s[1])-(4*s[0])) * sqrt((s[1]*s[1])-(4*s[0])) != (s[1]*s[1])-(4*s[0])) {cout << "0 0" << "\n";return;}
        else{
            if(b1 < 0 || b2 < 0) {cout << "0 0" << "\n";return;} //end this loop
            else{
                if(b1 > b2) {a = b1; b = b2;}
                else if(b2 > b1) {a = b2; b = b1;}
                else if (b2 == b1) {cout << "0 0" << "\n";return;}
            }
        }
        
    }
    else{
        b = 1;
        a = s[0]-1;
    }
    //cout << a << " " << b;
    //check----------------------------------------------------------------------------
    int cs = a-b;//checksubtraction
    int cm = a%b;//checkmod
    int cd = a/b;//checkdivide
    vector<int> check;
    check.push_back(cs);
    check.push_back(cm);
    check.push_back(cd);
    sort(check.begin(),check.end(),greater<int>());
    if(check[0]==s[2] && check[1]==s[3] && check[2]==s[4]) {cout << a << " " << b << "\n";return;}
    else {cout << "0 0" << "\n";return;}

}

int32_t main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        check();
        //check if theres more than 1 ans if so , 0 0 if not that.
    }

    return 0;
}