一名苦逼的OIer,想成为ACMer

Iowa_Battleship

BZOJ1228或洛谷2148 [SDOI2009]E&D

BZOJ原题链接

洛谷原题链接

完全不会呀。。
写了这题才知道\(SG\)函数原来也能打表找规律。。。
题解请看大佬的博客

#include<cstdio>
using namespace std;
inline int re()
{
	int x = 0;
	char c = getchar();
	bool p = 0;
	for (; c < '0' || c > '9'; c = getchar())
		p |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		x = x * 10 + c - '0';
	return p ? -x : x;
}
int main()
{
	int t, n, x, y, s, k, an, i;
	t = re();
	while (t--)
	{
		n = re();
		for (an = 0, i = 1; i <= n; i += 2)
		{
			s = 0;
			x = re() - 1;
			y = re() - 1;
			k = x | y;
			for (; k & 1; k >>= 1, s++);
			an ^= s;
		}
		an ? printf("YES\n") : printf("NO\n");
	}
	return 0;
}

posted on 2018-10-26 15:20  Iowa_Battleship  阅读(126)  评论(0编辑  收藏  举报

导航