ZOJ 2507 Let's play a game
题目链接: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的更多相关文章
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1392 The Hardest Problem Ever
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...
- ZOJ Problem Set - 1049 I Think I Need a Houseboat
这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...
- ZOJ Problem Set - 1006 Do the Untwist
今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...
- ZOJ Problem Set - 1001 A + B Problem
ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...
- zoj 1788 Quad Trees
zoj 1788 先输入初始化MAP ,然后要根据MAP 建立一个四分树,自下而上建立,先建立完整的一棵树,然后根据四个相邻的格 值相同则进行合并,(这又是递归的伟大),逐次向上递归 四分树建立完后, ...
- ZOJ 1958. Friends
题目链接: ZOJ 1958. Friends 题目简介: (1)题目中的集合由 A-Z 的大写字母组成,例如 "{ABC}" 的字符串表示 A,B,C 组成的集合. (2)用运算 ...
随机推荐
- 我的coding地址
https://dev.tencent.com/u/dtid_d6b0780bdefc3f9c/follower#1
- 基于MPI的大规模矩阵乘法问题
转载请注明出处. /* Function:C++实现并行矩阵乘法; Time: 19/03/25; Writer:ZhiHong Cc; */ 运行方法:切到工程文件x64\Debug文件下,打开命令 ...
- Web开发敏捷之道应用Rails 进行Web开发(原书第4版)遇到的问题
第11章:建立一个基于Ajax的购物车 原书是这样的: 问题:create.js.rjs rails4算是彻底抛弃rjs了,所以按照书上使用以下代码,是一点作用没有用的. 这里介绍一种方法: 1.在a ...
- H5页面移动端IOS键盘收起焦点错位
出现场景:IOS端,在弹出层点击input时调起键盘页面会被顶上去document.body.scrollOffset大于0,收起键盘时scrollOffset不变,造成焦点错位. 注:安卓手机点击时 ...
- 前端(HTML)初始
一.用socket实现HTML的原理 import socket sk = socket.socket() sk.bind(('127.0.0.1',8080)) sk.listen() while ...
- v8:: fatalProcessOutOfMemory
express项目,用于画图读写图片数据, pm2 作为进城守护. 生产环节报警:v8:: fatalProcessOutOfMemory,xxxx等,一时不知道什么原因. linux系统下使用如下命 ...
- 安装 mongo 4.0
Centos 使用yum安装MongoDB 4.0 1.配置MongoDB的yum源 创建yum源文件: #touch /etc/yum.repos.d/mongodb-org-4.0.repo 添加 ...
- python入门(十):模块、包
模块:py文件包:目录,目录里面包含__init__.py,内容可以是空里面可以包含多个模块文件,还可以包含子包 1.模块和包,可以很方便的提供给其他程序以复用 1) 利于组织复杂工程 我们写代码的时 ...
- hbuilder 打包 vueAPP
1:设置状态栏颜色 在manifest.json 找到 plus 下添加 "statusbar": { "immersed": true/*沉浸式状态栏*/ 设 ...
- nodejs设置跨域访问
//设置跨域访问app.all('*', function(req, res, next) { res.header("Access-Control-Allow-Origin", ...