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

18674번 - The Minions Quiz 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB42403794.872%

문제

The minions have finally found their new master. This time, he is a Math professor and he is trying very hard to teach them math. He has been teaching them bitwise operators for over a year! They learnt about AND(&) and OR (|) operators and it is time for a quiz to test them.

The quiz is very simple, they will be given a number A of AND(&) operators, a number B of OR (|) operators and (A + B + 1) integers. They have to find the maximum number that can be obtained by inserting the ‘&’ and ‘|’ operators between the given nonnegative integers without changing their order.

Finally, there is a special requirement for this quiz, they are required to evaluate the operators from left to right.

입력

The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100), followed by T test cases.

Each test case will consist of 2 lines. The first line will contain 2 integers A and B (0 ≤ A, B ≤ 10, 000) representing the number of AND(&) and OR (|) operators, respectively. The second line of input will consist of (A + B + 1) 64-bit nonnegative integers separated by single spaces.

출력

For each test case, output a single line containing the maximum number that can be obtained by inserting the operators between the given integers.

제한

예제 입력 1

2
1 1
1 4 5
2 2
2 3 11 4 5

예제 출력 1

5
7

힌트

출처

ICPC > Regionals > Africa and Arab > Arab Collegiate Programming Contest > 2015 Arab Collegiate Programming Contest E번

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

출처

대학교 대회

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

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