拆数字游戏

F - Spider Man
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit  Status  Practice  CodeForces 705B
Appoint description:  System Crawler  (Aug 12, 2016 3:03:09 AM)

Description

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.

Sample Input

Input
3
1 2 3
Output
2
1
1
Input
5
1 1 5 1 1
Output
2
2
2
2
2

Hint

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 12 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 1122 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 11112. 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个数字

如示例一1 2 3

1.当前数字为1:玩家1不能将1分解,玩家2赢

2.当前数字为1 2:玩家1直接将2分解成1 1,玩家2不能再分解,玩家1赢

3.当前数字为1 2 3:玩家1将2分解,玩家2对3分解(1 2)玩家1继续对2分解(1 1)玩家2无解,玩家1赢;

再如示例二1 1 5 1 1

1.当前数字1:玩家1无解,2赢

2.当前数字1 1:玩家1无解,2赢

3.当前数字1 1 5:玩家1对5分解(1 4),玩家2对4分解(1 3),玩家1对3分解(1 2),玩家2对2分解(1 1)玩家1无解,玩                                  家2赢

4.当前数字1 1 5 1 :同上,玩家1无解

5。当前数字1 1 5 1 1:同上。。

都要分成1,按分的步数,偶数2赢,奇数1赢

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include
  using namespace std;
  int main()
  {
      int n;
     while(~scanf("%d",&n))
 {        int x[100002],sum=0;
          for(int i=0; i<n; i++)
         {
             scanf("%d",&x[i]);
             sum+=x[i]-1;
             if(sum%2==0)printf("2\n");
             else printf("1\n");
         }
     }
     return 0;
}


你可能感兴趣的:(codeforces,编程语言,技巧性,==数学and思维==)