[CF705B] Spider Man - 博弈论

Posted mollnn

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[CF705B] Spider Man - 博弈论相关的知识,希望对你有一定的参考价值。

[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;
    }
}

以上是关于[CF705B] Spider Man - 博弈论的主要内容,如果未能解决你的问题,请参考以下文章

Spider_Man_3 の selenium

705 B. Spider Man

Spider_Man_3 の Mongodb_安装

Spider_Man_3 の BeautifulSoup

Spider_Man_5.2 の Mongodb_使用

Spider_Man_6 の Scrapy_Downloader Middleware(这是个需要针对一下的东西🐷🐷🐷)