| PPSC 2025 |
|---|
| Finished |
Tingyun gives you an array $$$a$$$ of size $$$n$$$.
Given an integer $$$x$$$, define functions $$$f_0(x),f_1(x),\ldots,f_n(x)$$$ as follows:
In other words, $$$f_n(x) = (\ldots((x \text{ mod } a_1)\text{ mod } a_2)\ldots \text{ mod } a_n)$$$.
Note for positive integers $$$a$$$ and $$$b$$$, $$$a \text{ mod } b$$$ is the unique integer $$$0\leq c \lt b$$$ such that $$$a-c$$$ is divisible by $$$b$$$. For example, $$$5 \text{ mod } 3 = 2$$$.
Tingyun then gives you $$$q$$$ values of $$$x$$$. For each $$$x$$$, please output the value of $$$f_n(x)$$$.
The first line contains an integer $$$t$$$ – the number of test cases ($$$1 \leq t \leq 10^4$$$).
The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \leq n,q \leq 10^5$$$).
The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \leq a_i \leq 10^9$$$).
The next $$$q$$$ lines each contain an integer $$$x$$$ ($$$1 \leq x \leq 10^9$$$).
It is guaranteed that neither the sum of $$$n$$$ nor the sum of $$$q$$$ exceeds $$$10^5$$$ over all test cases.
Scoring
Partial credits will be given to programs who pass tests with smaller constraints outlined below.
| Group | Points | Constraints |
| 1 | 20 | $$$q=1$$$ |
| 2 | 40 | $$$a_i, x \leq 50$$$, sum of $$$q\leq 3\cdot 10^4$$$ |
| 3 | 40 | No further constraints |
Output the answer for each $$$x$$$ on a new line.
23 315 13 1121452146255 614182 5527 2319 958 7248192489829128491578172857871267639126471891918273752
0 1 10 516 380 24 486 108 157
| Name |
|---|


