概述
另一类的公平组合游戏,台阶问题。
这一题的方法是我们只需要去异或奇数项(奇数台阶,从1开始)。
证明方法类似,如果对手动了偶数项台阶的石头那我们模仿他动奇数项台阶的石头,这样的话又能维护奇数项台阶石子相同。
import java.io.*;
class Main{
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw = new PrintWriter(System.out);
static int n;
public static void main(String[] args) throws IOException {
String[] s = br.readLine().split(" ");
n = Integer.parseInt(s[0]);
s = br.readLine().split(" ");
int res = Integer.parseInt(s[0]);
for (int i = 2; i < n; i +=2 ) res ^= Integer.parseInt(s[i]);
if (res != 0) pw.println("Yes");
else pw.println("No");
pw.flush();
pw.close();
br.close();
}
}
最后
以上就是怡然早晨为你收集整理的AcWing 892. 台阶-Nim游戏 (博弈论-公平组合游戏)的全部内容,希望文章能够帮你解决AcWing 892. 台阶-Nim游戏 (博弈论-公平组合游戏)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复