#P5675. [GZOI2017] 取石子游戏

    ID: 6416 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP博弈论2017各省省选O2优化贵州

[GZOI2017] 取石子游戏

Background

GZOI2017 D1T1

Problem Description

Alice and Bob are playing an ancient game. There are several piles of stones. Alice and Bob take turns to take stones. Each time, a player may choose one pile and take any number of stones from it, but they must take at least one stone. Whoever takes the last stone so that the other player cannot move wins.

Now there are NN piles of stones on the field, numbered from 11 to NN. Alice quickly discovered that this game has some fixed strategies. Cunning Alice wants to win this match, so she comes to you, the organizer, and asks you to select some piles from these NN piles as the piles used in the final game, such that Alice can win. Of course you do not want Alice to succeed, so you propose a condition: the pile that Alice takes from in her first move must be designated by you (you only designate the pile index, not how many stones she takes). This designated pile must be included among the piles chosen for the final game.

Now you are curious and want to compute how many different plans make it impossible for Alice to win. Note that even if the set of chosen pile indices is exactly the same, plans are still considered different if the designated pile index for the first move is different.

Input Format

The first line contains a positive integer NN, denoting the number of piles.

The second line contains NN positive integers, denoting the number of stones in each pile, given in order from pile 11 to pile NN.

Output Format

Output one line containing the number of plans. The answer should be taken modulo 109+710^9+7.

3
2 4 5
5
3
1 2 2
6

Hint

[Sample 11 Explanation]

The first plan: choose piles 11 and 22, and designate pile 11.

The second plan: choose piles 11 and 33, and designate pile 11.

The third plan: choose piles 11, 22, and 33, and designate pile 22.

The fourth plan: choose piles 11, 22, and 33, and designate pile 33.

The fifth plan: choose piles 22 and 33, and designate pile 22.

[Constraints]

Testdata ID NN Stones in each pile
11 5\le 5
22 10\le 10
33 100\le 100
44 200\le 200
55

Translated by ChatGPT 5