[CF705B]
Description
ICG 游戏有若干个环,每次操作将一个环断成非空的两部分,节点数总和不变。集合初态为空,每次向集合中添加一个环,询问当前集合用于游戏的胜负。 (n le 10^5, a_i le 10^9)
Solution
考虑每个环,如果我们将操作后产生的环都看作这个环的一部分,那么一个环一定在被操作 (a_i - 1) 次后就不能操作了。所以只需要判断 (sum{a_i - 1}) 的奇偶即可。
Code
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,a,s;
signed main()
{
ios::sync_with_stdio(false);
cin>>n;
for(int i=1; i<=n; i++)
{
cin>>a;
s+=a-1;
cout<<(s&1?1:2)<<endl;
}
}