Hello Coders!
The June edition of 101 Hack is here. 5 interesting challenges in 2 hours. The contest commences on 28th June 1:00 PM UTC. You can sign up for the contest here.
The problem statements will be available in English, Russian and Chinese.
Top 10 on leaderboard get cool HackerRank T Shirts
Problem Setters
darkshadows
amitp08
Bidhan
GL&HF
How was Problem 'XOR love' to be solved?
First calculate d[i][j], 1 <= i <= 20, 1 <= j <= N — how many numbers from A[1] .. A[j] have i'th bit set.
Now for each query (K, P, R) look at each 20 bits of K (20 because numbers do not exceed 10^6).
Calculate the following:
Can you explain why we are doing this?
if k has i'th bit set, only count pairs (A[i], A[j]) where both bits are not set or both bits are set, multiply the count by 1 << i
I will try after TopCoder SRM 626 ends if nobody has still explained it by that time ^.^
Well, multiplying by 2^i is obvious i guess, because we are calculating each bits occurance. And about bot set or bot nonset stuff, look at this equations:
K^ai^aj = 1 so,
If k=1 then thoose pairs are good
(0,0) , (1,1) else (0,1).