题解:P17109 「FAOI-R13」巴巴博弈

· · 题解

一、思路点拨

首先,一定有解,一定会有人胜利在第 n 轮,又因为两人都取最优策略,所以我们找两组数据。发现,后手在前 n 轮无法赢,所以只需判断 n 的奇偶,再加个快读即可。

二、AC code

附上代码:

#include<bits/stdc++.h>
using namespace std;
inline int read(){//快读不多说
    int x=0,f=1;
    char ch=getchar_unlocked();
    while(ch<'0'||ch>'9'){
        if(ch=='-'){
            f=-1;
            ch=getchar_unlocked();
        }
    }
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-48;
        ch=getchar_unlocked();
    }
    return x*f;
}
int main(){
    int t;
    t=read();
    while(t--){
        long long n;
        n=read();
        if(n%2==0){//不难发现
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}