Codeforces Round #760 (Div. 3) A. Polycarp and Sums of Subsequences

Codeforces Round #760 (Div. 3) A. Polycarp and Sums of Subsequences,第1张

Codeforces Round #760 (Div. 3) A. Polycarp and Sums of Subsequences

题目链接:Problem - A - Codeforces

Polycarp had an array aa of 3 positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array bb of 7 integers.

For example, if a={1,4,3}, then Polycarp wrote out 、1, 4, 3, 1+4=5, 1+3=4, 4+3=7, 1+4+3=8. After sorting, he got an array b={1,3,4,4,5,7,8}.

Unfortunately, Polycarp lost the array a. He only has the array bb left. Help him to restore the array a.

Input

The first line contains one integer t (1≤t≤5000) — the number of test cases.

Each test case consists of one line which contains 7 integers b1,b2,…,b7 (1≤bi≤109; bi≤bi+1).

Additional constraint on the input: there exists at least one array aa which yields this array bb as described in the statement.

Output

For each test case, print 3 integers — a1, a2 and a3. If there can be several answers, print any of them.

Example

input

5
1 3 4 4 5 7 8
1 2 3 4 5 6 7
300000000 300000000 300000000 600000000 600000000 600000000 900000000
1 1 2 999999998 999999999 999999999 1000000000
1 2 2 3 3 4 5

output

1 4 3
4 1 2
300000000 300000000 300000000
999999998 1 1
1 2 2

Note

The subsequence of the array aa is a sequence that can be obtained from aa by removing zero or more of its elements.

Two subsequences are considered different if index sets of elements included in them are different. That is, the values of the elements don't matter in the comparison of subsequences. In particular, any array of length 3 has exactly 7 different non-empty subsequences.

题意:给你3个数字a, b,c,然后把a,b,c,a + b, a + c, b + c, a + b + c,从小到大排序;现在给你这7个数字,构造出a, b, c;

思路:7个数中第一个数肯定是三个数的其中一个,第二的也是,最后一个肯定是3数之和,所以第三个数就是总和减去前两个

#include
using namespace std;

int arr[10];
int main(){
	int t;
	cin >> t;
	while(t--){
		for(int i = 0; i < 7; i++){
			cin >> arr[i];
		}
		int a = arr[0];
		int b = arr[1];
		int c = arr[6] - arr[0] - arr[1];
		cout << a << " " << b << " " << c << endl;
	}
	return 0;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5670740.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存