ZOJ 2507 Let's play a game

时间:2022-08-27 09:07:19

题目链接: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 &plus; B Problem

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

  8. zoj 1788 Quad Trees

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

  9. ZOJ 1958&period; Friends

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

随机推荐

  1. Mvc请求管道中的19个事件

    下面是请求管道中的19个事件. (1)BeginRequest: 开始处理请求 (2)AuthenticateRequest授权验证请求,获取用户授权信息 (3):PostAuthenticateRe ...

  2. 实施vertex compression所遇到的各种问题和解决办法

    关于顶点压缩,好处是可以减少带宽,一定程度提高加载速度,可以提高约5-10%的fps,特别是mobile上,简单描述就是: 压缩之前(32字节) position float3 12normal fl ...

  3. HDU 5776 sum &lpar;BestCoder Round &num;85 A&rpar; 简单前缀判断&plus;水题

    分析:就是判断简单的前缀有没有相同,注意下自身是m的倍数,以及vis[0]=true; #include <cstdio> #include <cstdlib> #includ ...

  4. django datetime format 日期格式化

    django datetime format 日期格式化 www.jx-lab.com python 中 date,datetime,time对象都支持strftime(format)方法,但有一些区 ...

  5. Android该系统提供的服务--Vibrator&lpar;振子&rpar;

    Android该系统提供的服务--Vibrator(振子) --转载请注明出处:coder-pig Vibrator简单介绍与相关方法: watermark/2/text/aHR0cDovL2Jsb2 ...

  6. 兔子--Spring基金会

    设计模式的基本目的: 对象之间的解耦.使用容器来管理组件.减少不同组件之间的耦合 控制返回,搜索请求委托给容器 将积极考虑被动接受 版权声明:本文博主原创文章,博客,未经同意不得转载.

  7. ●BZOJ 2119 股市的预测

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=2119 题解: 这个题很好的. 首先把序列转化为差分序列,问题转化为找到合法的子序列,使得去除 ...

  8. Android设置shape后改变颜色

    如下,可能多个btn的设置同一个shape,如果单独改变btn颜色,可以用如下代码 GradientDrawable btnPreDrawable = (GradientDrawable) btnTe ...

  9. MT【69】斯图姆定理

    评:如果说零点存在定理是"只在此山中,云深不知处"的意境.那么斯图姆定理就能处理多项式的零点个数以及定位.

  10. ThreadLocal的练习代码

    场景: 有三个小孩儿,买了一个变形金刚玩具(Transformer).... 三个小孩都争着玩这个玩具....没有一个人可以玩... 第一种方式:每个人各玩一会.... 第二种方式:再买两个玩具,一个 ...