QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 128 MB Total points: 100

#2858. Sequence Counting

Statistics

Alice wants to obtain a sequence of length $n$, where each number in the sequence is a positive integer not exceeding $m$, and the sum of these $n$ numbers is a multiple of $p$.

Alice also hopes that among these $n$ numbers, at least one is a prime number.

Alice wants to know how many such sequences satisfy her requirements.

Input

A single line containing three integers $n$, $m$, and $p$.

Output

A single integer representing the number of sequences that satisfy Alice's requirements. Since the number of such sequences can be very large, output the result modulo $20170408$.

Constraints

For $20\%$ of the data, $1 \le n \le 100$, $1 \le m \le 100$ For $50\%$ of the data, $1 \le m \le 100$ For $80\%$ of the data, $1 \le m \le 10^6$ For $100\%$ of the data, $1 \le n \le 10^9$, $1 \le m \le 2 \times 10^7$, $1 \le p \le 100$

Examples

Input 1

3 5 3

Output 1

33

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.