Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Arya and OR

By MosharrafOshy · Limits 1s, 512 MB

Little Arya loves to play with numbers. She likes to play in different ways with them. One day she started playing with numbers by bitwise OR operation. The game is that, she has N numbers. She will choose some random group of numbers from those N numbers. She will apply Bitwise OR operation between them and get a resultant number M.

Now, she wants to know the maximum value of M that she can find out from that arbitrary group of numbers after applying Bitwise OR operation.


At first your program will take T as a test case (1 ≤ T ≤ 10). Then it will take input for each test case. First line of test case will take N (1 ≤ N ≤ 100). Next line has N numbers (0 ≤ Ni ≤ 106)


At first print test case number just like sample output “Case X: ”, X is the test case number , with the maximum numbers M as described in the problem.


2 3
7 8
Case 1: 3
Case 2: 15

Bitwise OR ( | ) operation

A	B	Result
0	0	0
0	1	1
1	0	1
1	1	1



93% Solution Ratio

minhaz110Earliest, Jun '16

Bishal_GFastest, 0.0s

asfaklus2Lightest, 0 B

bokaifShortest, 105B


Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.