F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Remove

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1316    Accepted Submission(s): 313


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
1 6 2 2 3
 

Sample Output
17181031198765592570
 

Hint

In the sample case, ai is {1,1,2,3,3,0}.
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-20 01:43:59, Gzip enabled