Logo
(追記) (追記ここまで)

24239번 - Coins 다국어인터랙티브

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

문제

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

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /