GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Saturday 25 June 2022

[Solution] NIT orz! Codeforces Solution | Codeforces Problem Solution 2022


A. NIT orz!
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

NIT, the cleaver, is new in town! Thousands of people line up to orz him. To keep his orzers entertained, NIT decided to let them solve the following problem related to orz. Can you solve this problem too?

You are given a 1-indexed array of n integers, a, and an integer z. You can do the following operation any number (possibly zero) of times:

  • Select a positive integer i such that 1in. Then, simutaneously set ai to (aiorz) and set z to (aiandz). In other words, let x and y respectively be the current values of ai and z. Then set ai to (xory) and set z to (xandy).

Here or and and denote the bitwise operations OR and AND respectively.

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

Find the maximum possible value of the maximum value in a after any number (possibly zero) of operations.

Input
Each test contains multiple test cases. The first line contains the number of test cases t (1t100). Description of the test cases follows.

The first line of each test case contains two integers n and z (1n20000z<230).

The second line of each test case contains n integers a1,a2,,an (0ai<230).

It is guaranteed that the sum of n over all test cases does not exceed 104.

Output

For each test case, print one integer — the answer to the problem.

No comments:

Post a Comment