Submission

Status:

[PPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: iij

Problemset: anna

Language: cpp

Time: 0.003 second

Submitted On: 2025-10-23 11:40:30

#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;
int main() {
    int n;
    cin >> n;

    while (n--) {
        int c = 0, ansx, ansy;
        long long a[5];
        for (int i = 0; i < 5; i++) cin >> a[i];

        sort(a, a+5);
        do {
            long double xf = (a[0] + a[1])/2;
            long double yf = (a[0] - a[1])/2;

            long long x = xf, y = yf;
            if (x <= 0 || y <= 0 || x <= y || x != xf || y != yf) continue;

            if (x+y==a[0] && x-y==a[1] && x*y==a[2] && x%y==a[3] && floor(x/y)==a[4]) {
                ansx = x, ansy = y;
                c++;
                if (c >= 2) break;
            }
        } while (next_permutation(a, a+5));

        if (c == 1) printf("%d %d\n", ansx, ansy);
        else printf("0 0\n");
    }
}