Remove

TimeLimit:3000MS  MemoryLimit:262144KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
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.
SampleInput
1
6 2
2
3
SampleOutput
17181031198765592570

 Hint In the sample case, ai is {1,1,2,3,3,0}.
Submit
题目统计信息详细
总AC数1
通过人数1
尝试人数1
总提交量1
AC率100.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: