HDU 1730 Northcott Game(nim博弈)
2014-09-16 14:19
465 查看
题目地址:HDU 1730
由于每次如果黑方向左移动棋子,白方都可以在同行的白色棋子向左移动相同的距离,对结果没影响。所以转换成了一个nim游戏。
代码如下:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
int n, m, a, b, sum;
while(scanf("%d%d",&n,&m)!=EOF)
{
sum=0;
while(n--)
{
scanf("%d%d",&a,&b);
if(a>b) swap(a,b);
sum^=b-a-1;
}
if(sum)
puts("I WIN!");
else
puts("BAD LUCK!");
}
return 0;
}
由于每次如果黑方向左移动棋子,白方都可以在同行的白色棋子向左移动相同的距离,对结果没影响。所以转换成了一个nim游戏。
代码如下:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
int n, m, a, b, sum;
while(scanf("%d%d",&n,&m)!=EOF)
{
sum=0;
while(n--)
{
scanf("%d%d",&a,&b);
if(a>b) swap(a,b);
sum^=b-a-1;
}
if(sum)
puts("I WIN!");
else
puts("BAD LUCK!");
}
return 0;
}
相关文章推荐
- HDU 1730 Northcott Game (Nim博弈)
- HDU 1730 Northcott Game (Nim博弈)
- HDU 1730 Northcott Game (Nim博弈)
- HDU 1730 Northcott Game (Nim博弈)
- hdu 1730 Northcott Game (Nim博弈)
- HDU 1730 Northcott Game (Nim博弈)
- HDU 1730 Northcott Game (Nim博弈)
- HDU 1730 Northcott Game(Nim博弈变形)
- HDU 1730 Northcott Game (Nim博弈)
- hdu 1730 Northcott Game (nim博弈变形)
- HDU 1730 - Northcott Game(博弈)
- 杭电hdu 1730 Northcott Game 博弈
- (step 8.2.11)hdu 1730(Northcott Game——NIM游戏变形)
- HDU 1730 Northcott Game(Nim game)
- hdu1730 Northcott Game(s-nim)
- HDU-1730-Northcott Game【nimm 博弈】
- HDU 1730 Northcott Game 【组合博弈】
- hdu1730 Northcott Game,Nim-sum
- HDOJ 1730 Northcott Game(nim博弈)
- HDU_1730 Northcott Game(博弈)