#P3702. [SDOI2017] 序列计数

    ID: 1715 远端评测题 3000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2017各省省选山东素数判断,质数,筛法容斥矩阵乘法快速傅里叶变换 FFT

[SDOI2017] 序列计数

Description

Alice wants to obtain a sequence of length nn, where all elements are positive integers not exceeding mm, and the sum of these nn numbers is a multiple of pp.

Alice also wants at least one of these nn numbers to be a prime number.

Alice wants to know how many sequences satisfy her requirements.

Input Format

One line with three integers, n,m,pn, m, p.

Output Format

One line with a single number: the number of sequences that satisfy Alice’s requirements, taken modulo 2017040820170408.

3 5 3
33

Hint

For 20%20\% of the testdata, 1n,m1001 \leq n, m \leq 100.

For 50%50\% of the testdata, 1m1001 \leq m \leq 100.

For 80%80\% of the testdata, 1m1061 \leq m \leq 10^6.

For 100%100\% of the testdata, $1 \leq n \leq 10^9, 1 \leq m \leq 2 \times 10^7, 1 \leq p \leq 100$.

Translated by ChatGPT 5