zoukankan      html  css  js  c++  java
  • [atcoder caddi2018]D.Harlequin——博弈论

    题目大意:

    给定n堆石子,每一次可以从不同的堆中取1个石子或者不取,求最后的谁获胜。

    思路:

    一种状态E全部都是偶数,另外一种状态O即存在奇数。
    不难发现最后的状态为E。
    如果拿到了E不论怎么操作都会变成O,如果拿到了O总有办法变成E,即先手必胜的状态为O,先手必败的状态为E。

    #include<bits/stdc++.h>
    
    #define REP(i,a,b) for(int i=a,i##_end_=b;i<=i##_end_;++i)
    #define DREP(i,a,b) for(int i=a,i##_end_=b;i>=i##_end_;--i)
    #define debug(x) cout<<#x<<"="<<x<<endl
    #define fi first
    #define se second
    #define mk make_pair
    #define pb push_back
    typedef long long ll;
    
    using namespace std;
    
    void File(){
    	freopen("d.in","r",stdin);
    	freopen("d.out","w",stdout);
    }
    
    template<typename T>void read(T &_){
    	_=0; T f=1; char c=getchar();
    	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
    	for(;isdigit(c);c=getchar())_=(_<<1)+(_<<3)+(c^'0');
    	_*=f;
    }
    
    const int maxn=1e5+10;
    int n,a[maxn];
    
    int main(){
    	File();
    	read(n);
    	REP(i,1,n)read(a[i]);
    	REP(i,1,n)if(a[i]%2)return puts("first"),0;
    	puts("second");
    	return 0;
    }
    
    
  • 相关阅读:
    第八周总结和实验六
    第七周总结与实验五
    遍历目录中的所有文件和目录,并生成全路径
    python watchdog
    Offer_answer_with_SDP_rfc3264
    [转]UML八大误解
    leetcode周赛220
    Codeforces Round #690 (Div. 3)
    学习资料
    鱼眼图与六面图转换(python)
  • 原文地址:https://www.cnblogs.com/ylsoi/p/10163420.html
Copyright © 2011-2022 走看看