NR2 - Bhagat The Bit Man
Bhagat is student of CSE at ISM Dhanbad. In mid-semsester exam somehow he was able to score full marks in Boolean algebra. So his profs doubt how can he score full marks. So profs decided to check his ability. They gave Bhagat a list student’s admission number and ask him to find total kaptiness (K) of list.
Kaptiness is defined as or operation on every dukkerness(di) value. Dukkerness value is xor operation on every pair of number in list.As we all know Bhagat is not good in Boolean algebra. Can you help him to prove his profs that he can score full out of full in boolean algebra.
If list contain three number 10, 15 & 17.Then there will be total 3 pairs.
d1 = 10 ^ 15 = 5;
d2 = 10 ^ 17 = 27;
d3 = 17 ^ 15 = 30;
k = d1 | d2 | d3 ;
K = 31;
First line of input contain N (2 <= N <= 106). N is total number of admission number(ai) in list.
Then following N line will contain admission number. (0 <= ai <=1018)
Output only one line containing K.
Input: 3 10 15 17 Output: 31
NOTE: Large input data. >
test cases have been updated and all solutions are rejudged.
If you are using left shift then use 1LL<<j instead of 1<<j as the value will cross the integer range. It costed me 3 WA
Worth solving learnt a lot!!!
Nice and simple .. :)
comments are spoilers :P !
Learnt Something New , thanks To K MAPS
It's easy if u didn't neglect K-Maps in HIGH SCHOOL
try this one to have fun with some Boolean Algebra
use scanf/printf instead of cin/cout ...
Realy enjoyed....nice problem....