#P3321. [SDOI2015] 序列统计

    ID: 2370 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2015山东素数判断,质数,筛法概率论,统计快速傅里叶变换 FFT

[SDOI2015] 序列统计

Description

Xiao C has a set SS whose elements are non-negative integers less than mm. He wrote a sequence generator that can generate a sequence of length nn, where every term belongs to the set SS.

Xiao C generated many such sequences. However, he needs your help with the following question: given an integer xx, count how many different sequences can be generated such that the product of all numbers in the sequence mod m\bmod \ m equals xx.

Xiao C considers two sequences AA and BB different if and only if i s.t. AiBi\exists i \text{ s.t. } A_i \neq B_i. Since the answer may be large, he only needs the answer modulo 10045358091004535809.

Input Format

One line with four integers n,m,x,Sn, m, x, |S|, where S|S| is the number of elements in the set SS.
The second line contains S|S| integers, representing all elements of the set SS.

Output Format

Output a single integer on one line, representing the answer.

4 3 1 2
1 2
8

Hint

Sample explanation:

The different sequences that can be generated and satisfy the requirement are (1,1,1,1)(1,1,1,1), (1,1,2,2)(1,1,2,2), (1,2,1,2)(1,2,1,2), (1,2,2,1)(1,2,2,1), (2,1,1,2)(2,1,1,2), (2,1,2,1)(2,1,2,1), (2,2,1,1)(2,2,1,1), (2,2,2,2)(2,2,2,2).

Constraints:

For 10%10\% of the testdata, 1n10001 \le n \le 1000.
For 30%30\% of the testdata, 3m1003 \le m \le 100.
For 60%60\% of the testdata, 3m8003 \le m \le 800.
For 100%100\% of the testdata, 1n1091 \le n \le 10^9, 3m80003 \le m \le 8000, 1x<m1 \le x < m.
mm is a prime, and the input guarantees that the elements in set SS are distinct.

Translated by ChatGPT 5