Codeforces 750B. Spider Man


Peter Parker wants to play a game with Dr. Octopus. The game is about cycles.Cycleis 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 arekcycles,i-th of them consisting of exactlyvivertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least2vertices (for example,xvertices) among all available cycles and replace it by two cycles withpandx - pvertices where1 ≤ p < xis 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 withaivertices 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 integern(1 ≤ n ≤ 100 000)— the number of tests Peter is about to make.

The second line containsnspace separated integersa1, a2, ..., an(1 ≤ ai ≤ 109),i-th of them stands for the number of vertices in the cycle added before thei-th test.

Output

Print the result of all tests in order they are performed. Print1if the player who moves first wins or2otherwise.

根据把所有尽量分成数量为2的堆的总步数和分完后2堆的数目之和的奇偶性来判断

#include<iostream>
#include<cstring>
#include<cstdio>
#include <string>
#include<map>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long LL;

int n;
LL numtwo(0),steps(0);
int main(){
  // freopen("test.in","r",stdin);
  cin >> n;
  for (int i=1;i<=n;i++){
    LL now;
    cin >> now;
    if (now == 2) numtwo++;
    if (now > 2){
      numtwo += now / 2;
      if (now % 2){
        steps += now / 2;
      }
      else
        steps += now / 2 - 1;
    }
    // cout << numtwo << " " << steps << endl;
    if((numtwo+steps)% 2){
      cout << 1 << endl;
    }
    else
      cout << 2 << endl;
  }
  return 0;
}
View Code

优质内容筛选与推荐>>
1、64位Ubuntu14.04搭建ADT开发环境
2、CTR预估的常用方法
3、android 广播
4、Redis Sentinel实现的机制与原理详解
5、各种oracle10g下载地址(官网网页上好像找不到了)


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn