题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5552
题 意:有1到n个数字,两个人轮流选1个数,并把它的所有约数去掉。去掉最后一个数的人赢,输先手必胜还是必败。
思 路:假设有先手必败,那么此时取1,得到的剩下的情况仍旧会是先手必败,矛盾
所以先手必胜,注意特判0
代码如下:
#include <iostream>
using namespace std;
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <algorithm>
int main()
{
int n;
while( scanf ( "%d", &n ) != EOF )
{
if( n == 0 )
{
printf("fail\n");
}
else printf("win\n");
}
return 0;
}