#P7413. [USACO21FEB] Stone Game G
[USACO21FEB] Stone Game G
Description
Bessie and Elsie are playing a game with () piles of stones. For each , the -th pile contains stones (). The two cows take turns, and Bessie moves first.
- First, Bessie chooses a positive integer and removes stones from some pile that has at least stones.
- Then Elsie chooses a positive integer such that divides , and removes stones from some pile that has at least stones.
- Then Bessie chooses a positive integer such that divides , and removes stones from some pile that has at least stones, and so on.
- In general, the number of stones removed on turn , , must divide .
The first cow who cannot remove stones on her turn loses.
Compute the number of possible first moves that guarantee Bessie a win (meaning there exists a strategy such that no matter how Elsie plays, Bessie will win). Two first moves are considered different if either the number of stones removed is different, or the pile chosen is different.
Input Format
The first line contains .
The second line contains space-separated integers .
Output Format
Output the number of first moves that guarantee Bessie a win (meaning there exists a strategy such that no matter how Elsie plays, Bessie will win).
Note that the integer sizes in this problem may require using 64-bit integers (for example, long long in C/C++).
1
7
4
6
3 2 3 2 3 1
8
Hint
Explanation for Sample 1:
Bessie can win if she removes , , , or stones from the only pile. In this case, the game ends immediately.
Explanation for Sample 2:
Bessie can win if she removes or stones from any pile. After that, the two cows will alternate removing the same number of stones, and Bessie makes the last move.
Test Point Properties:
- For an additional of the testdata, .
- For an additional of the testdata, .
- For an additional of the testdata, there are no additional constraints.
Problem by: Benjamin Qi.
Translated by ChatGPT 5
京公网安备 11011102002149号