GlobeX Cup '18 S3 - Playing With Bits
View as PDFAugust is doing his binary math homework. While doing it, he came up with a problem, and thought it would be a good problem to put on the GlobeX Canada Cup.
August gives you 3 questions. Given the integers , 
, 
, and 
, how many ways are there to make an integer array 
 of length 
 where 
 such that:
?
?
?
Note that:
denotes the bitwise
xoroperation (^in most languages).denotes the bitwise
oroperation (|in most languages).denotes the bitwise
andoperation (&in most languages).
Since August has meganumerophobia, he wants the answer to each question modulo .
Input Specification
The first line and only line will contain  space-separated integers 
 
.
Output Specification
On the first line, output the answer to question 1, modulo .
On the second line, output the answer to question 2, modulo .
On the last line, output the answer to question 3, modulo .
Subtasks
Subtask 1 [5%]
Subtask 2 [15%]
Subtask 3 [60%]
Subtask 4 [20%]
No additional constraints.
Sample Input 1
2 1000000007 3 5
Sample Output 1
8
9
3
Sample Input 2
8 1000000007 1 0
Sample Output 2
128
1
255
Comments