#NC2401A. A Bit Common
A Bit Common
题目描述
Given two integers and , among all the sequences containing non-negative integers less than , you need to count the number of such sequences that there exists a non-empty subsequence of in which the bitwise AND of the integers is .
Note that a non-empty subsequence of a sequence is a non-empty sequence that can be obtained by deleting zero or more elements from and arranging the remaining elements in their original order.
Since the answer may be very large, output it modulo a positive integer .
The bitwise AND of non-negative integers and , is defined as follows:
- When is written in base two, the digit in the 's place () is if those of and are both , and otherwise.
For example, we have = (in base two: = ).
Generally, the bitwise AND of non-negative integers is defined as and we can prove that this value does not depend on the order of .
输入格式
The only line contains three integers , and .
输出格式
Output a line containing an integer, denoting the answer.
2 3 998244353
17
5000 5000 998244353
2274146