Logo
(追記) (追記ここまで)

23948번 - The Equation 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
15 초 (추가 시간 없음) 1024 MB60262150.000%

문제

The laws of the universe can be represented by an array of N non-negative integers. The i-th of these integers is Ai.

The universe is good if there is a non-negative integer k such that the following equation is satisfied: (A1 xor k) + (A2 xor k) + ... (AN xor k) ≤ M, where xor denotes the bitwise exclusive or.

What is the largest value of k for which the universe is good?

입력

The first line of the input gives the number of test cases, T. T test cases follow. Each test case begins with a line containing the two integers N and M, the number of integers in A and the limit on the equation, respectively.

The second line contains N integers, the i-th of which is Ai, the i-th integer in the array.

출력

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the largest value of k for which the universe is good, or -1 if there is no such k.

제한

  • 1 ≤ T ≤ 100.
  • 1 ≤ N ≤ 1000.

Test Set 1 (12점)

  • 0 ≤ M ≤ 100.
  • 0 ≤ Ai ≤ 100, for all i.

Test Set 2 (20점)

  • 0 ≤ M ≤ 1015.
  • 0 ≤ Ai ≤ 1015, for all i.

예제 입력 1

4
3 27
8 2 4
4 45
30 0 4 11
1 0
100
6 2
5 5 1 5 1 0

예제 출력 1

Case #1: 12
Case #2: 14
Case #3: 100
Case #4: -1

힌트

In sample case #1, the array contains N = 3 integers and M = 27. The largest possible value of k that gives a good universe is 12 ((8 xor 12) + (2 xor 12) + (4 xor 12) = 26).

In sample case #2, the array contains N = 4 integers and M = 45. The largest possible value of k that gives a good universe is 14 ((30 xor 14) + (0 xor 14) + (4 xor 14) + (11 xor 14) = 45).

In sample case #3, the array contains N = 1 integer and M = 0. The largest possible value of k that gives a good universe is 100 (100 xor 100 = 0).

In sample case #4, there is no value of k that gives a good universe, so the answer is -1.

출처

Contest > Google > Kick Start > Google Kick Start 2019 > Round G B번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /