|
||||||||||
RemoveTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1610 Accepted Submission(s): 368 Problem Description Kris is playing a game, which involves removing stones from a pile that initially consists of $n$ stones. He is given a set of prime numbers $P$, and each time he is able to choose one $p$ from $P$ and remove $m\bmod p$ stones from the pile, where $m$ stands for the number of stones remaining in the pile. The game finishes once no stone is left in the pile, and he wants to put an end to the game using least number of rounds possible. Given $N$, you are expected to calculate the minimum rounds $a_n$ required to finish the game starting with a pile of $n$ stones for all $1\le n\le N$. And if there is no possible solution for certain $n$, we set $a_n=0$. And in order to prevent large output, you only need to print $\left(\sum_{1\le n\le N}a_n\times 23333^{N-n}\right)\bmod 2^{64}$. Input This problem contains multiple test cases. The first line contains an integer $T(1\le T\le 60)$, the number of test cases. Each case starts with a line of two integers $N,|P|(1\le N\le 2\times 10^6, 1\le |P|\le 10^5)$. Then $|P|$ prime integers follow, denoting the set. It is guaranteed that the primes are pairwise different and do not exceed $N$. There will be no more than $15$ test cases where $N\ge 20000$. Output Output $T$ lines, each line contains an integer, the answer for the corresponding test case. Sample Input
Sample Output
Hint In the sample case, ai is {1,1,2,3,3,0}. Source | ||||||||||
|