"About CF"
Title Link: CF 705B
Surface:
B. Spider mantime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard 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 are connected with the second, second are connected with third And so on, while the last one was 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 Least2 vertices (for example, x vertices) among all available cycles and replace it by-cycles With p and x ?-? P vertices where1?≤? 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 thei-th Test He adds a cycle with ai vertices to the set (this is actually a multis Et 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?000)-the number of tests Peter is on to make.
The second line contains n space separated integersa1,? A2,?...,? An (1?≤? ) Ai-≤?109),i-th of them stands for the number of vertices in the C Ycle added before thei-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.
Examplesinput
31 2 3
Output
211
Input
51 1 5) 1 1
Output
22222
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 with2. 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 L OSes.
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 Size1 and one with size 2 . Now cycles Have1 , 1 , 2 , Span class= "Tex-span" >2 vertices. Second player ' s only move was to replace a cycle of Size2 with 2 cycles of Size1 . And cycles is 1 , 1 , 1 , Span class= "Tex-span" >1 , 2 . First player replaces the last cycle with 2 cycles with Size1 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 sizes1 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 Size1 . 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 PLA Yer would replace the cycle of size 3 with "Sizes1 and 2 . Now the cycles with more than one vertex is a cycles of Size2 . As shown in previous case, with 2 cycles of size 2 second play ER wins.
So, either-on-the-first player loses.
Test instructions
Game game, a pile of numbers, can be split into two non-empty, all the heap can not be demolished, then the loss. Each time you add a new heap, ask for the winning or losing situation in all of the current heaps.
Solving:
Because a number n, can be dismantled for a fixed number of n-1 times, so long as the total number of operations can be counted, see the sum of the parity can be.
Code:
#include <iostream>#include <cstdio>#defineLLLong Longusing namespaceSTD;intMain(){intN;LL sum=0,tmp;Cin>>N; while(N--){Cin>>tmp;sum+=tmp-1;if(sum%2)cout<<1<<Endl; Elsecout<<2<<Endl; }return 0;}
"Play CF, learn algorithm--Two star" Codeforces 705B Spider man (simple game)