B. Spider Man
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard 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.

Input

The 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.

Output

Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise.

Examples
input
3
1 2 3
output
2
1
1
input
5
1 1 5 1 1
output
2
2
2
2
2
Note

In 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.

水题,判断一下奇偶性就可以了

 #include<bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=b;++i)
using namespace std; int main(){
int n,cnt=,tp;
scanf("%d",&n);
F(i,,n)
{
scanf("%d",&tp),tp--;
cnt+=tp;
if(cnt&)puts("");
else puts("");
if(cnt&)cnt=;else cnt=;
}
return ;
}

Codeforces Round #366 (Div. 2)_B. Spider Man的更多相关文章

  1. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  2. Codeforces Round #366 Div.2[11110]

    这次出的题貌似有点难啊,Div.1的Standing是这样的,可以看到这位全站排名前10的W4大神也只过了AB两道题. A:http://codeforces.com/contest/705/prob ...

  3. Codeforces Round #366 (Div. 2)

    CF 复仇者联盟场... 水题 A - Hulk(绿巨人) 输出love hate... #include <bits/stdc++.h> typedef long long ll; co ...

  4. Codeforces Round #366 (Div. 2) B 猜

    B. Spider Man time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  5. Codeforces Round #366 (Div. 2) A , B , C 模拟 , 思路 ,queue

    A. Hulk time limit per test 1 second memory limit per test 256 megabytes input standard input output ...

  6. Codeforces Round #347 (Div.2)_B. Rebus

    题目链接:http://codeforces.com/contest/664/problem/B B. Rebus time limit per test 1 second memory limit ...

  7. Codeforces Round #290 (Div. 2) _B找矩形环的三种写法

    http://codeforces.com/contest/510/status/B 题目大意 给一个n*m  找有没有相同字母连起来的矩形串 第一种并查集 瞎搞一下 第一次的时候把val开成字符串了 ...

  8. Codeforces Round #366 (Div. 2) B

    Description Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a ...

  9. Codeforces Round #366 (Div. 2) C 模拟queue

    C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...

随机推荐

  1. JavaWeb开发中的乱码问题

    一,获取系统平台的默认编码 获取系统平台的默认编码: String encoding=System.getProperty("file.encoding"); 注:至于UTF-8编 ...

  2. 一步步优化JVM四:决定Java堆的大小以及内存占用

    到目前为止,还没有做明确的优化工作.只是做了初始化选择工作,比如说:JVM部署模型.JVM运行环境.收集哪些垃圾回收器的信息以及需要遵守垃圾回收原则.这一步将介绍如何评估应用需要的内存大小以及Java ...

  3. js 中的 exec( )方法

    JavaScript exec() 方法 JavaScript RegExp 对象 定义和用法 exec() 方法用于检索字符串中的正则表达式的匹配. 语法:RegExpObject.exec(str ...

  4. shrio配置说明

    1.引入Shiro的Maven依赖 <!-- Spring 整合Shiro需要的依赖 --> <dependency> <groupId>org.apache.sh ...

  5. gimagex 2.0.17 汉化版

    软件名称: gimagex 2.0.17 汉化版 软件语言: 简体中文 授权方式: 免费软件 运行环境: Win 32位/64位 软件大小: 1.31MB 图片预览: 软件简介: gimagex 2. ...

  6. LanSoEditor_common ---android平台的视频编辑SDK

    当前版本是LanSoEditor-v1.4 主要使用在音视频的: 裁剪,剪切,分离,合并,转换,拼接,水印,叠加,混合,转码等场合; 我们是针对android平台对ffmpeg做了硬件加速优化,经过多 ...

  7. 视频编辑类sdk--lansoeditor--更新啦, 完全免费,欢迎下载

    当前版本是20160506 beta, 增加了兼容高通的64位硬件编码器增加MediaInfo类,您可以轻松获取多媒体中的各种信息.增加了演示的15个ffmpeg处理方法,您可以用这些方法实现秒拍图像 ...

  8. 【JS】倒计时

    描述: 先要链接jquery.js,这样写法可以直接放JS文件运行. //放在图片里定位的倒计时 //顶图里面定位才使用的代码 document.writeln("<style> ...

  9. STM32F2系列系统时钟默认配置

    新到一家公司后,有个项目要用到STM32F207Vx单片机,找到网上的例子照猫画虎的写了几个例子,比如ADC,可是到了ADC多通道转换的时候就有点傻眼了,这里面的时钟跑的到底是多少M呢?单片机外挂的时 ...

  10. WWW 资源下载与表单提交

    在注册与验证用户信息,以及非即时通信的游戏中,我们可以使用WWW类使用短链接来完成客户端与服务器数据的通信,今天我们将使用用POST方法来完成的用户注册与登录,在最后介绍下其它资源的加载. 首先使用P ...