B. Spider Man
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex.
Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p andx - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!).
Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In thei-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins?
Peter is pretty good at math, but now he asks you to help.
InputThe first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make.
The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test.
OutputPrint the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise.
Examplesinput3
1 2 3output2
1
1input5
1 1 5 1 1output2
2
2
2
2NoteIn the first sample test:
In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses.
In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses.
In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins.
In the second sample test:
Having cycles of size 1 is like not having them (because no one can make a move on them).
In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2and 3.
- If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses.
- If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins.
So, either way first player loses.
题意:
就是n个环,每个环有ai个结点,Peter Parker和Dr. Octopus博弈,Peter Parker先手当环内结点数>1时,可将该环分成两个环,分别为k个结点和ai-k个结点问随着环数的增加,谁会赢?Peter Parker赢输出"1";否则输出"2"。
题目不难 题意难!!题面太长的水题也算是难题啊好吧QAQ
说白了还是判断奇偶吗。
附AC代码:
#include<bits/stdc++.h>
using namespace std; int main()
{
int n,s,i;
long long ans=;
cin>>n;
for(i=;i<n;i++)
{
cin>>s;
ans+=s-;
if(ans%)
cout<<""<<endl;
else
cout<<""<<endl;
}
return ;
}
p.s.
昨晚cf开场时间还是蛮友好的~趴在床上水过A题正在看B题题意时室友突然跑进来抱走我电脑看柯南去了-_-# 果不其然又掉分了...
B. Spider Man的更多相关文章
- spider RPC入门指南
本部分将介绍使用spider RPC开发分布式应用的客户端和服务端. spider RPC中间件基于J2SE 8开发,因此需要确保服务器上安装了JDK 8及以上版本,不依赖于任何额外需要独立安装和配置 ...
- Scrapy:为spider指定pipeline
当一个Scrapy项目中有多个spider去爬取多个网站时,往往需要多个pipeline,这时就需要为每个spider指定其对应的pipeline. [通过程序来运行spider],可以通过修改配置s ...
- spider RPC过滤器
spider支持在请求执行前或完成后进行特殊处理,比如安全性检查.敏感字段混淆等等.为此,spider提供了BeforeFilter和AfterFilter.其执行位置如下图所示: 流水线插件配置在s ...
- spider RPC插件化体系
为了满足灵活扩展的需要,spider支持灵活的自定义插件扩展,从功能上来说,插件和过滤器的差别在于过滤器不会阻止请求的执行同时对于主程序不会有API上的影响(比如servlet 过滤器和监听器)(最多 ...
- spider RPC管理接口
为了在独立管理模式下尽可能的容易运行时排查问题,spider中间件提供了一系列restful api用于动态管理当前节点的路由,下游节点等.目前支持的RESTFUL API如下所示: 功能 服务号 R ...
- spider RPC高级特性
多租户 spider原生支持多租户部署,spider报文头对外开放了机构号.系统号两个属性用于支持多租户场景下的路由. 多租户场景下的路由可以支持下述几种模式: n 系统号: n 系统号+服务号( ...
- spider RPC安全性
spider提供了多重安全保障机制,目前主要支持接入握手校验,报文完整性校验,报文加密,报文长度检查四种机制. 接入认证 spider使用两次握手校验,其握手流程如下: 签名AES加密的方式实现. l ...
- spider RPC开发指南
协议与兼容性 spider使用java语言开发,使用Spring作为IoC容器,采用TCP/IP协议,在此基础上,结合SaaS系统模式的特性进行针对性和重点设计,以更加灵活和高效的满足多租户系统.高可 ...
- spider 配置文件参考
spider有一个配置文件spider.xml,为xml格式,spider.xml采用DTD进行管理,用于管理spider的所有特性.路由.高可用等. 配置文件支持三种不同的方式进行指定: 1. 通过 ...
- spider RPC性能测试报告
测试环境部署结构 测试用例 类 别 说明 请求报文 194字节({"systemId":"PL","appVersion":"qq ...
随机推荐
- 【grpc】项目启动缺少grpc架包引用
项目启动缺少grpc架包引用 导致 项目无法启动 解决方法: 在命令行执行 ./gradlew generateProto 下载完成之后 刷新gradle或者maven 再重启项目
- 【转】 C++ 简单的 Tcp 实现[socket] 客户端与客户端通信
// 服务器端代码 // Server.cpp : Defines the entry point for the console application.// #include "std ...
- vmware Unable to open kernel device "\\.\Global\vmx86": The system cannot find the file 的解决方法
https://communities.vmware.com/thread/245800?start=0&tstart=0 I have exactly same issue. I star ...
- 安卓APK瘦身
之前打包的时候直接就用eclipse或者android studio直接生成签名文件,并没有关心大小问题,近期有人问我有没有对APK进行瘦身.对这方面内容一致没有关注过,今天试用了各种方式把项目签名a ...
- INAPP登陆调用的FB接口
public function login_get (){ $this->load->helper ( 'auth' ); $redirectUrl = $this->input-& ...
- C#读取指定路径下的Config配置文件
ExeConfigurationFileMap map = new ExeConfigurationFileMap(); map.ExeConfigFilename = @"F:\App1. ...
- 常用shell命令的写法
这并不是教人怎么进行shell编程的文章,只是韦哥在工作中用到的一些简单脚本的写法.因为有些命令即使用过几次了,再次使用时仍然写不对,需要man来看下或者需要google,你也可以理解为对命令的理解不 ...
- JAVA BigDecimal 高精度运算
文章参考一位博友,由于时间太久忘了链接,见谅! public class BigDecimalUtils { private static final int DIV_SCALE = 10;// 除法 ...
- PandoraBox 支持3G无线上网卡(联通卡3G卡)(一)
一:笔者采用的是系统是OpenWrt之PandoraBox,内核版本3.3.8:硬件设备是MTK的7620开发板. 其中怎么搭建openwrt开发环境在此不用多说,因为既然想实现3G无线上网卡拨号上网 ...
- Python开发【2.2 异常处理】
1.Python常见异常类型: Exception 常规错误的基类 AttributeError 对象没有这个属性 IOError 输入/输出操作失败 IndexError 序列中没有此索引(inde ...