Wesley++

View as PDF

Submit solution

Points: 12 (partial)
Time limit: 0.5s
Memory limit: 1G

Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Wesley's template has everything, except for good support for interactive problems and fast arbitrary precision integer arithmetic. For now.

Wesley is playing a game against Lesley. They are both standing in front of a pile of N pebbles and will alternate turns. On a person's turn, they may take 2^X pebbles from the pile for some nonnegative integer X. The person who takes the last pebble from the pile wins. Wesley gets to choose whether he goes first or second. Help Wesley win.

Constraints

N \le 10^{1000}

Input

This is an interactive problem. You will first read a single integer N. After that, you will either print 1 to say that Wesley wants to go first or you will print 2 to say that Wesley wants to go second.

On Wesley's turn, you must print an integer X indicating that Wesley will take X pebbles. On Lesley's turn, you will read in an integer X indicating that Lesley took X pebbles.

Make sure to flush your output. Terminate with exit code 0 when the game is over, otherwise your program may get an undefined verdict.

Sample Interaction Details

<<< indicates values that you read in, >>> indicates values that you print out.

Sample Interaction 1

3 <<<
>>> 2
1 <<<
>>> 2

Sample Interaction 2

4 <<<
>>> 1
>>> 4

Comments

There are no comments at the moment.