http://www.lydsy.com/JudgeOnline/problem.php?id=1115

题意:n堆石子,个数是从左到右单增。每一次可以从任意堆取出任意石子,但要保持单增这个性质。问先手是否必胜(n<=1000, a[i]<=10000)

#include <bits/stdc++.h>
using namespace std;
int n, a[1005];
int main() {
	int T; scanf("%d", &T);
	while(T--) {
		scanf("%d", &n);
		for(int i=1; i<=n; ++i) scanf("%d", &a[i]);
		for(int i=n; i; --i) a[i]-=a[i-1];
		int s=0;
		for(int i=n; i>0; i-=2) s^=a[i];
		s?puts("TAK"):puts("NIE");
	}
	return 0;
}

  

简单的阶梯博弈..

发现向前差分后每一次减少一堆相当于把石子往后边丢,于是从后向前阶梯即可。

相关文章:

  • 2021-06-03
  • 2022-01-11
  • 2022-02-14
  • 2021-11-03
  • 2022-02-09
  • 2021-10-07
  • 2021-10-22
  • 2021-09-06
猜你喜欢
  • 2021-11-05
  • 2021-06-02
  • 2021-11-27
  • 2021-10-10
  • 2022-12-23
  • 2021-09-24
  • 2021-07-03
相关资源
相似解决方案