Codeforces Round #366 (Div. 2) B

Source: Internet
Author: User

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 are connected with the second, second are connected with third and So on and the last one are connected with the first one again. Cycle may consist of a isolated vertex.

Initially there Are  K  cycles,  I -th of them consisting of Exactly  v i  vertices. Players Play alternatively. Peter goes first. On each turn a player must choose a cycle with at Least 2 vertices (for EXAMPLE,&NBSP; x  vertices) among all available cycles and replace it by-cycles With  p  and  x - p  vertices where < Span class= "Tex-span" >1≤ P < x  is chosen by the player. The player 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 the i-th Test He adds a cycle with ai vertices to the set (this is actually a mu Ltiset because it can contain or more identical cycles). After all test, Peter wants to know so if the players begin the game with the current set of cycles, who wins?

Peter is pretty good at math, but now he asks

Input

The first line of the input contains a single integer n (1≤ n ≤100)-the number of tests Peter is on-to-make.

The second line contains n space separated integers a1, a2, ..., a N ( 1≤ ai ≤109), i-th of them stands for the number of Ver Tices in the cycle added before the i-th test.

Output

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

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 He 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 the cycles of 1 vertex and second player can ' t do any move and loses.

In his third Test, cycles has1,2 and3 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 size1 and one with size 2. Now Cycles has 1, 1,2, 2 vertices. Second player ' s only move was 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 are like do not have 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 both options:replace it with cycles of sizes 1 and 4 or 2 and 3.

  • If He replaces it with cycles of Sizes 1 and 4:only Second cycle matters. Second player would replace it with 2 cycles of Sizes 2. First player's only option to replace one of the them with the 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 would replace the cycle of size 3 with both of Siz Es 1 and 2. Now the cycles with more than one vertex is the cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins.

So, either-on-the-first player loses.

Test instructions: Give you the number of I in turn, ask the last person left the array, all the numbers can not be broken down into two numbers even if the loss.

Solution: The number is decomposed into two numbers, no matter how you divide it, the number of decomposition is the same, then the initiator to win, only in his time left an odd number of decomposition times

The number of decomposition times of 2 is 1,3 for 2,4, and the decomposition times for 3,n is n-1;

We add up in turn and judge the parity.

#include <bits/stdc++.h>using namespace Std;long long a[100005];int N,m;long long Sum[1000005];int Main () {    cin>>n;    for (int i=1;i<=n;i++)    {        cin>>a[i];        sum[i]=sum[i-1]+ (a[i]-1);    }    for (int i=1;i<=n;i++)    {        if (sum[i]%2==1)        {            cout<< "1" <<endl;        }        else        {            cout<< "2" <<endl;        }    }    return 0;}

  

Codeforces Round #366 (Div. 2) B

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.