File tree Expand file tree Collapse file tree 2 files changed +50
-118
lines changed Expand file tree Collapse file tree 2 files changed +50
-118
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
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
+ */
You can’t perform that action at this time.
0 commit comments