栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

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

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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;
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/665472.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号