[Solution] Single Operation Part 1 CodeChef Solution
Problem
Chef has the binary representation of a number with him. He can modify the number by applying the following operation exactly once:
- Make , where and denotes the bitwise XOR operation.
Chef wants to maximize the value of after performing the operation. Help Chef in determining the value of which will maximize the value of after the operation.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of two lines of inputs - the first containing the length of binary string .
- The second line of input contains the binary string .
Output Format
For each test case, output on a new line, the value of which will maximize the value of after the operation.
Explanation:
Test case : Since is the binary representation of , the current value of . On choosing , becomes . We can show that this is the maximum value of we can achieve after one operation.
Test case : Since is the binary representation of , the current value of . On choosing , becomes . We can show that this is the maximum value of we can achieve after one operation.
Test case : Since is the binary representation of , the current value of . On choosing , becomes . We can show that this is the maximum value of we can achieve after one operation.
Test case : Since is the binary representation of , the current value of . On choosing , becomes . We can show that this is the maximum value of we can achieve after one operation.
No comments:
Post a Comment