#P4706. 取石子
取石子
Description
Now Yopilla and yww are going to play a game.
They mark points on a straight line, numbered from left to right as . Then they place some stones on each point: point has stones. Next, starting from Yopilla, the two players take turns. Whoever cannot make a move loses. Each move is:
The current player chooses a point that has stones, then chooses at least one stone from point , and moves all chosen stones to point , where is a prime number and .
Yopilla's strategy for the very first move is random: he randomly picks a point that has stones, randomly chooses a positive integer number of stones , and randomly moves them to a reachable point . All stones are considered identical. In other words, two moves are different if and only if the triple is different. After that, both players play with optimal strategies.
Yopilla wants to predict the probability that he can win. Output the answer modulo .
Input Format
The first line contains one integer .
The second line contains integers .
Output Format
Output one line, representing the probability that Yopilla can win modulo .
3
3 1 2
332748118
Hint
Explanation of the sample:
Point has stones, point has stone, and point has stones. On the first move, there are three possible moves: move the stone at point to point ; move stone at point to point ; move stones at point to point . Among these, only one case allows Yopilla to have a winning strategy. So the answer is
For of the testdata, there is only one stone.
For of the testdata, , . It is guaranteed that there is at least one stone not at point .
Translated by ChatGPT 5
京公网安备 11011102002149号