Snakes and Ladders | 프로그래밍의 벗 PivotOJ
PivotOJ

Snakes and Ladders

시간 제한: 1000ms메모리 제한: 128MB출처: CCC 2003 SeniorBOJ 6905
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

[이미지 1]Here (see illustration) is a game board for the game Snakes and Ladders. Each player throws a pair of dice to determine how many squares his/her game piece will advance. If the piece lands on the bottom of a ladder, the piece moves up to the square at the top of the ladder. If the piece lands on the top of a snake, the piece "slides" down to the square at the bottom of the snake. If the piece lands on the last square, the player wins. If the piece cannot advance the number of squares indicated by the dice, the piece is not moved at all.

In order to help you play this game via a cell phone while travelling, you will write a program that simulates your moves on the board shown and, of course, runs on your handheld computer. You will repeatedly throw the dice and enter the result into the program. After each throw, the program will report the number of the square where your piece lands.

When the program starts it should assume the piece is on square 11. It should repeatedly read input from the user (a number between 22 and 1212) and report the number of the square where the piece lands. In addition, if the piece moves to the last square, the program should print You Win! and terminate. If the user enters 0 instead of a number between 2 and 12, the program should print You Quit! and terminate.

For clarity, you are to use the board pictured above and you should note that the board has 33 snakes (from 5454 to 1919, from 9090 to 4848 and from 9999 to 7777) and 3 ladders (from 99 to 3434, from 4040 to 6464 and from 6767 to 8686).

예제

예제 1

입력
9
11
12
7
3
5
10
9
출력
You are now on square 10
You are now on square 21
You are now on square 33
You are now on square 64
You are now on square 86
You are now on square 91
You are now on square 91
You are now on square 100
You Win!
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.