【BZOJ 1115】【POI 2009】石子游戏Kam

http://www.lydsy.com/JudgeOnline/problem.php?id=1115
差分后变成阶梯博弈。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 1003;

int a[N], n, s;

int main() {
	int T; scanf("%d", &T);
	while (T--) {
		scanf("%d", &n);
		for (int i = 1; i <= n; ++i) scanf("%d", a + i);
		s = 0;
		for (int i = n; i >= 1; i -= 2) s ^= a[i] - a[i - 1];
		puts(s ? "TAK" : "NIE");
	}
	return 0;
}
posted @ 2017-03-18 08:23  abclzr  阅读(154)  评论(0编辑  收藏  举报