【Codeforces Round #366 (Div. 2)】Codeforces 705B Spider Man

Peter Parker wants to play a game with Dr. Octopus. The game is about
cycles. Cycle is a sequence of vertices, such that first one is
connected with the second, second is connected with third and so on,
while the last one is connected with the first one again. Cycle may
consist of a single isolated vertex.

Initially there are k cycles, i-th of them consisting of exactly vi
vertices. Players play alternatively. Peter goes first. On each turn a
player must choose a cycle with at least 2 vertices (for example, x
vertices) among all available cycles and replace it by two cycles with
p and x - p vertices where 1 ≤ p < x is chosen by the player. The
player who cannot make a move loses the game (and his life!).

Peter wants to test some configurations of initial cycle sets before
he actually plays with Dr. Octopus. Initially he has an empty set. In
the i-th test he adds a cycle with ai vertices to the set (this is
actually a multiset because it can contain two or more identical
cycles). After each test, Peter wants to know that if the players
begin the game with the current set of cycles, who wins?

Peter is pretty good at math, but now he asks you to help. Input

The first line of the input contains a single integer n
(1 ≤ n ≤ 100 000) — the number of tests Peter is about to make.

The second line contains n space separated integers a1, a2, …, an
(1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the
cycle added before the i-th test. Output

Print the result of all tests in order they are performed. Print 1 if
the player who moves first wins or 2 otherwise.

很显然的结论,一堆总数为n的石子无论如何操作,总是恰好需要n-1次操作。所以只需要判断总操作次数的奇偶即可。

#include<cstdio>
int main()
{
    int i,j,k,n,x,y,z;
    int now=0;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if (!(x&1)) now=!now;
        if (now) printf("1\n");
        else printf("2\n");
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值