Summer Practice Race 003 A Spider Man

Source: Internet
Author: User

A-spider Mans

crawling in process ... crawling failed time limit:2000MS Memory Limit:262144KB 64bit I O Format:%i64d &%i64u

Submit Status

Description

Input

Output

Sample Input

Sample Output

Hint

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 is 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, x vertices) among all available cycles and replace it by-cycles with p a nd x - p vertices where 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 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

Sample Output

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 over the cycle with 1 vertex. First player can replace the second cycle with a cycles of 1 Vertex and second player can ' t make Any move and loses.

In his third Test, cycles has 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 a size 1 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 S ize 1. And cycles is 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 sizes 1 and 2. Now the cycles with more than one vertex is one 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.

/*very water topic, regret died, the topic too long lazy to see understand test instructions ...*/#include<iostream>#include<stdio.h>#include<cmath>#include<vector>#include<algorithm>#include<string.h>#defineN 100010#defineM 100000using namespacestd;intMain () {//freopen ("In.txt", "R", stdin);    intT; Long Longa,s=0; scanf ("%lld",&t);  for(intI=1; i<=t;i++) {scanf ("%lld",&a); //if (a==1)s+=A; Long Longt=s-i; if(t%2) puts ("1"); Elseputs ("2"); }    return 0;}

Summer Practice Race 003 A Spider Man

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.