시간 제한메모리 제한제출정답맞힌 사람정답 비율
20 초 512 MB110141116.667%

문제

I have a set of positive integers S. Can you find two non-empty, distinct subsets with the same sum? 

Note: A subset is a set that contains only elements from S, and two subsets are distinct if they do not have exactly the same elements.

입력

The first line of the input gives the number of test cases, TT test cases follow, one per line. Each test case begins with N, the number of positive integers in S. It is followed by Ndistinct positive integers, all on the same line.

Limits

  • No two numbers in S will be equal.
  • 1 ≤ T ≤ 10.
  • N is exactly equal to 500.
  • Each number in S will be a positive integer less than 1012.

출력

For each test case, first output one line containing "Case #x:", where x is the case number (starting from 1).

  • If there are two different subsets of S that have the same sum, then output these subsets, one per line. Each line should contain the numbers in one subset, separated by spaces.
  • If it is impossible, then you should output the string "Impossible" on a single line.

If there are multiple ways of choosing two subsets with the same sum, any choice is acceptable.

 

 

예제 입력 1

2
20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
20 120 266 858 1243 1657 1771 2328 2490 2665 2894 3117 4210 4454 4943 5690 6170 7048 7125 9512 9600

예제 출력 1

Case #1:
1 2
3
Case #2:
3117 4210 4943
2328 2894 7048

출처

Contest > Google > Code Jam > Google Code Jam 2012 > Round 1B C2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.