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)用运算 ...
随机推荐
- ng 1.2 ng-bind-html 用法
使用ng-bind-html渲染html字符串时需要在控制器外注册$sec 过滤器 //过滤器渲染html字符串 app.filter('to_trusted',['$sce',function($s ...
- session的处理机制
https://blog.csdn.net/deepwishly/article/details/6659613 https://blog.csdn.net/dz45693/article/detai ...
- ssh 使用技巧
参考:https://deepzz.com/post/how-to-setup-ssh-config.html SSH Config 那些你所知道和不知道的事 预览目录 配置项说明 相关技巧 管理多组 ...
- JS防抖与节流函数封装
防抖 在监听scroll事件的时候经常会用到防抖,当滚动到某一位置而触发状态,从而不会出现频繁滚动持续触发事件的情况 防抖的事件处理机制仅触发一次且必须是结束状态下才会执行 function debo ...
- sphinx-2.1.9的安装使用
1.下载/编译安装 cd /usr/local/src wget http://sphinxsearch.com/files/sphinx-2.1.9-release.tar.gz tar -xf s ...
- [原创] debian 9.3 搭建Jira+Confluence+Bitbucket+crowd+seafile (零) 修改端口的问题
[原创] debian 9.3 搭建Jira+Confluence+Bitbucket+seafile (零) 修改端口的问题 来来来,今天说个没有人说过的事, 搭建好Jira+Confluenc ...
- windows安装tf
https://www.cnblogs.com/lvsling/p/8672404.html
- H5(ionic2+VScode) 环境安装
一:node.js.npm.cnpm.cordova环境安装 介绍下概念 node.js 非阻塞异步的Ajax 操作基础框架. npm 国外的node.js 包管理器 cnpm 国内淘宝的node.j ...
- 100-days: twenty-seven
Title: Criticism for China's child modeling(代指从事模特行业的人) industry after video of 3-year-old being kic ...
- byte -> int
传送门 传送门2 以下copy: int i = 0; i += ((b[0] & 0xff) << 24); i += ((b[1] & 0xff) <&l ...