[恢]hdu 1730

2011-12-26 23:03:00

地址:http://acm.hdu.edu.cn/showproblem.php?pid=1730

题意:中文。

mark:sg,nim博弈。每行考虑两个棋子之间的距离。每次减小距离。增大距离是没有意义的,因为对手下一步可以执行同样的策略来减小。

代码:

# include <stdio.h>


int abs(int n){return n<0?-n:n;}


int main ()
{
int i, n, m, sg, a, b ;
while (~scanf ("%d%d", &n, &m))
{
sg = 0 ;
for (i = 0 ; i < n ; i++)
{
scanf ("%d%d", &a, &b) ;
sg ^= abs(a-b)-1;
}
puts (sg == 0 ? "BAD LUCK!" : "I WIN!") ;
}
return 0 ;
}



原文地址:https://www.cnblogs.com/lzsz1212/p/2315367.html