&+ +&
Time limit1.5sMemory limit512 MB
Over all N^2 pairs, compute the sum modulo 1999 of pairwise ANDs, and the bitwise AND of all pairwise sums.
- Level
Medium5 of 10
- Topics
- Bit manipulation, Math, Implementation
- Solved
- No attempts yet
Problem
Two positive integer sequences of length are given: and . For every ordered pair with and , compute the following two values.
- The remainder of the sum of all divided by
- The bitwise AND of all values
is bitwise AND. Its definition is in the Hint section.
Input
The first line gives the sequence length (). The second line gives integers of sequence , separated by spaces, and the third line gives integers of sequence , separated by spaces. Every element of and is a positive integer with .
Output
Print the two values described above on the first line, separated by a space, in order.
Hint
Bitwise AND applies to each binary digit. Write both operands in binary first, then set a digit to only when both operands have there, and to otherwise.
As an illustration, . Here is in binary and is . After aligning digits to and , the digitwise AND is , which equals in decimal.