loj#P6696. 复读机 加强版
复读机 加强版
Description
We call a sequence good iff and for all , the occurrences of in is a multiple of . Please count the number of good sequences. Since the answer could be extremely large, you just need to calculate it modulo .
Input Format
One line with three positive integers .
Output Format
Output one integer which is the answer modulo .
8 3 4
213
12 4 6
5548
Limits
For of the testcases, .
For the rest of the testcases, .
It's guaranteed that .