Skip to content

Commit 538f8b5

Browse files
committed
Added Maximum Array XOR problem
1 parent 920ad8c commit 538f8b5

File tree

2 files changed

+50
-118
lines changed

2 files changed

+50
-118
lines changed

Codechef Problems/FlappyBird.java

Lines changed: 0 additions & 118 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Implementation of Maximum Array XOR problem from CodeChef
3+
*
4+
* Problem name: Maximum Array XOR problem
5+
* Problem code: MAXARXOR
6+
* Problem link: https://www.codechef.com/START7C/problems/MAXARXOR
7+
*/
8+
import java.util.*;
9+
import java.lang.*;
10+
import java.io.*;
11+
12+
class MaximumArrayXOR
13+
{
14+
public static void main (String[] args) throws java.lang.Exception
15+
{
16+
Scanner sc=new Scanner(System.in);
17+
int t=sc.nextInt();
18+
19+
while(t-->0)
20+
{
21+
long count=0;
22+
long N=sc.nextInt();
23+
long K=sc.nextInt();
24+
25+
count=(long)Math.pow(2,N);
26+
27+
if(K>=count/2)
28+
K=count/2;
29+
30+
count=(count-1)*K*2;
31+
32+
System.out.println(count);
33+
34+
}
35+
}
36+
}
37+
/*
38+
* Sample Input 1
39+
* 3
40+
* 2 0
41+
* 2 1
42+
* 10 100
43+
*
44+
* Sample Output 1
45+
* 0
46+
* 6
47+
* 204600
48+
*
49+
* Time complexity: O(n)
50+
*/

0 commit comments

Comments
 (0)