编程介的小学生
2017-11-18 00:47Trouble
10Problem Description
Hassan is in trouble. His mathematics teacher has given him a very difficult problem called 5-sum. Please help him.
The 5-sum problem is defined as follows: Given 5 sets S_1,...,S_5 of n integer numbers each, is there a_1 in S_1,...,a_5 in S_5 such that a_1+...+a_5=0?
Input
First line of input contains a single integer N (1≤N≤50). N test-cases follow. First line of each test-case contains a single integer n (1<=n<=200). 5 lines follow each containing n integer numbers in range [-10^15, 1 0^15]. I-th line denotes set S_i for 1<=i<=5.
Output
For each test-case output "Yes" (without quotes) if there are a_1 in S_1,...,a_5 in S_5 such that a_1+...+a_5=0, otherwise output "No".
Sample Input
2
2
1 -1
1 -1
1 -1
1 -1
1 -1
3
1 2 3
-1 -2 -3
4 5 6
-1 3 2
-4 -10 -1
Sample Output
No
Yes
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- 如何使用PHP函数连接HTML <img>?
- javascript
- php
- 2个回答
- 使用一些php文件在GAE上托管一个大多数静态的网站
- html
- filepath
- php
- 1个回答
- 这个问题如果用费用流的方式计算序列,怎么实现会比较好,用C语言,谢谢
- r语言
- Golang
- erlang
- 1个回答
- Snail’s trouble
- each
- it
- 1个回答
- The trouble of Xiaoqian
- c
- it
- numbers
- x
- each
- 4个回答