PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000344. Đếm bộ ba bội số có XOR bằng 0 (Nim)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm bộ ba bội số có XOR bằng 0 (Nim)
Nim
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given integers , count ordered triples of positive integers satisfying all conditions:
- for all .
- divides for all .
- , where denotes bitwise XOR.
Print the answer modulo . The positions of the values matter.
Input
One line containing .
Output
Print the count of valid triples modulo .
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Examples
Example 1
Input
13 2 3 5
Output
4
Explanation
The four valid triples are , , , and ; each satisfies the divisibility and XOR requirements.
Example 2
Input
1000000000000000000 1 1 1
Output
426724011
Explanation
This maximum-bound case requires bitwise digit DP instead of enumeration. The result is reduced modulo .