跳到正文

题解

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

原文
文章信息与版本

文章信息

收录
2026年8月2日
更新
2026年8月4日
篇幅
约 1 分钟
获赞
2
题目
P17109

版本

  1. v1当前

一、思路点拨

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

二、AC code

附上代码:

C++
#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;
}
原文