hdu 2897 (博弈)

点击打开链接


题意:

给你n个石子,每次取x个x>=p&&x<=q,当石子数小于p时,必须全部取完,求第一个人能否胜利。。

p=2;q=4

n:

1->负

2->负

3->胜

4->胜

5->胜

6->胜

7->负

8->负

9.10.11.12胜

循环节为p+q。

#include"stdio.h"
#include"string.h"
int main()
{
	int n,p,q;
	while(scanf("%d%d%d",&n,&p,&q)!=-1)
	{
		n=n%(p+q);
		if(n>0&&n<=p)puts("LOST");
		else puts("WIN");
	}
	return 0;
}




你可能感兴趣的:(博弈,X)