Say xor NO!
InterviewTime limit1sMemory limit1024 MB
Count the pairs of numbers from two lists whose bitwise XOR is smaller than K.
- Level
Medium6 of 10
- Topics
- Trie, Bit manipulation
- Solved
- No attempts yet
Problem
Puangi, Chung-Ang University's proud Blue Dragon, has a song he enjoys listening to these days. It is 'Say xor NO!' from 〈Show me the Chung-Ang〉. Puangi fell for the song and made 'Say' cards and 'NO!' cards to compute 'Say xor NO!' as the title says.

When a 'Say' card bearing integer and a 'NO!' card bearing integer are drawn, the value of the 'Say xor NO!' operation for the two cards is defined as .
Puangi, who turns this year, wonders how many card pairs produce a 'Say xor NO!' result smaller than his age. Write a program to compute that number for Puangi.
Input
The first line gives the number of 'Say' cards (), the number of 'NO!' cards (), and Puangi's age (). The second line gives the numbers on the 'Say' cards, separated by spaces. The third line gives the numbers on the 'NO!' cards, separated by spaces. ()
Output
Print the number of card pairs whose bitwise xor result is less than .
Hint
The definition of the xor operation can be found here.