题目链接: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 ;
}

ZOJ 2507 Let's play a game的更多相关文章

  1. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  2. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  3. ZOJ Problem Set - 1394 Polar Explorer

    这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...

  4. ZOJ Problem Set - 1392 The Hardest Problem Ever

    放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...

  5. ZOJ Problem Set - 1049 I Think I Need a Houseboat

    这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...

  6. ZOJ Problem Set - 1006 Do the Untwist

    今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...

  7. ZOJ Problem Set - 1001 A + B Problem

    ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...

  8. zoj 1788 Quad Trees

    zoj 1788 先输入初始化MAP ,然后要根据MAP 建立一个四分树,自下而上建立,先建立完整的一棵树,然后根据四个相邻的格 值相同则进行合并,(这又是递归的伟大),逐次向上递归 四分树建立完后, ...

  9. ZOJ 1958. Friends

    题目链接: ZOJ 1958. Friends 题目简介: (1)题目中的集合由 A-Z 的大写字母组成,例如 "{ABC}" 的字符串表示 A,B,C 组成的集合. (2)用运算 ...

随机推荐

  1. gridcontrol 根据某一列数据来控制其他列合并

    首先需要属性栏中设置这一列可以合并,再在CellMerge方法中写 private void gridView1_CellMerge(object sender, DevExpress.XtraGri ...

  2. 尚硅谷springboot学习35-启动原理

    先列出几个重要的事件回调机制 配置在META-INF/spring.factories ApplicationContextInitializer SpringApplicationRunListen ...

  3. Spring中利用applicationContext.xml文件实例化对象和调用方法

    Spring中实例化对象和调用方法入门 1.jar包和xml的准备 已上传至百度云盘,链接: https://pan.baidu.com/s/1CY0xQq3GLK06iX7tVLnp3Q 提取码: ...

  4. php解决高并发问题

    我们通常衡量一个Web系统的吞吐率的指标是QPS(Query Per Second,每秒处理请求数),解决每秒数万次的高并发场景,这个指标非常关键.举个例子,我们假设处理一个业务请求平均响应时间为10 ...

  5. ubuntu中文乱码解决

    首先,安装中文支持包language-pack-zh-hans: $ sudo apt-get install language-pack-zh-hans 然后,修改/etc/environment( ...

  6. JS实现简单斗地主效果

    let play = document.querySelectorAll(".play"); let dizhupai = document.getElementById(&quo ...

  7. 4、promise

    es5 中 var obj = { ajax: function (callback) { console.log('执行') setTimeout(function () { callback &a ...

  8. ORACLE升级11g以上之前版本的wm_concat()函数失效

    先执行: create or replace type string_sum_obj as object ( --聚合函数的实质就是一个对象 sum_string ), static function ...

  9. iis网站部署常见错误

    sqlserver 授权登录名没有db_owner权限 数据库连接字符串端口没开,连接形式:192.168.0.1,1433

  10. 获取select下拉框选中的的值

    有一id=test的下拉框,怎么获取选中的那个值呢? 分别使用javascript方法和jquery方法 <select id="test"  name="&quo ...