시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB100644457.143%

문제

You have been challenged by the infamous magician Zhivago to his signature coin game! The game starts off with a pile of $n$ coins, where you and Zhivago will each take turns grabbing coins from the pile, and the loser is the one that grabs the last coin. Each player has to take $1$, $2$ or $3$ coins each turn; no more, no less!

Zhivago is a master in his own game, and will always play optimally. However, you have been informed that you are in a winning position, and can best Zhivago to become the coin game champion. Can you do it?

인터랙션

First, your program should read a single integer $ 1 \leq n < 1000$, the number of coins in the pile at the start of the game. Then, we repeat the following process:

  • Your program writes a single line to the standard output, in the form of an integer $1$, $2$ or $3$ that represents the move you make.
  • After you have made your move, then your program should read a single integer $c \in \{1, 2, 3\}$ representing how many coins Zhivago takes on his turn.
  • If there is only a single coin left for Zhivago, he will output the string "I give up" instead. At this point your program should terminate.

After making each move, do not forget to flush the output. To do this, use:

  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • stdout.flush() or print(output, flush=True) in Python;
  • see documentation for other languages.

예제

Your output Zhivago output Interpretation
  7 There are $ n = 7 $ coins as the starting amount in the pile.
2 1 You take $2$ coins and Zhivago responds by taking $1$ coin.
3 I give up You take $3$ coins. Since there is only $1$ coin left, Zhivago gives up.

출처

Contest > Bergen Open > Bergen Open 2021 C번

  • 문제를 만든 사람: Kristoffer Æsøy

채점 및 기타 정보

  • 예제는 채점하지 않는다.