题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1507

MisereNim博弈。代码如下:

 //============================================================================
// Name : test.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================ #include <iostream>
#include <math.h>
#include <stdio.h>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <string>
#include <sstream>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <cmath>
#include <set>
#define SCF(a) scanf("%d", &a)
#define IN(a) cin>>a
#define FOR(i, a, b) for(int i=a;i<b;i++)
#define Infinity 999999999
#define NInfinity -999999999
#define PI 3.14159265358979323846
#define MAXN 1000000005
#define RATIO (sqrt(5.0)+1.0)/2.0
typedef long long Int;
using namespace std; int main()
{
int t;
int n;
SCF(t);
while (t--)
{
SCF(n);
int ans = ;
int num;
bool flag = false;
FOR(i, , n)
{
SCF(num);
if (num > )
flag = true;
ans = ans^num;
}
if (flag)
{
if (ans == )
printf("2\n");
else
printf("1\n");
}
else
{
if (ans == )
printf("1\n");
else
printf("2\n");
}
}
return ;
}
05-11 17:20