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

6874번 - Cross Spiral 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB208880.000%

문제

In an old house there is a room that is shaped like a cross. You can think of a cross as being an outlining rectangle with four smaller rectangles cut out of the corners. The floor of the room is completely covered with square tiles. Bridget is walking around the room, stepping from one tile to the next, spiraling towards the centre. Bridget always walks clockwise and stays as close to the edge of the room as possible without stepping on any tile twice. It is possible that she may be trapped and unable to move to an adjacent tile before reaching all the tiles in the room.

Assume that the upper left corner of the outlining rectangle is position (1, 1), that is column 1 and row 1. The walk always starts at column X and row 1, where X is the leftmost column of row 1 in the cross. The tile at position (X, 1) cannot be revisited during the walk, however the first step is counted when Bridget moves to an adjacent tile.

Write a program that calculates Bridget’s final column and row position in the room after the walk. The program must accept input for the dimensions of the cross: i.e. the width and height of the outlining rectangle, the width and height of the “cut out” rectangles, and the number of steps the person will take. In the diagram, the inputs for the dimensions of the cross are: 10 8 3 2 In other words, the outlining rectangle is 10 units wide and 8 units high. The “cut out” rectangles are 3 units wide and 2 units high.

The maximum width and height of the outlining rectangle will be 20 x 20. The minimum width of the cross will be 1. The vertical and horizontal parts of the cross are not necessarily the same width.

입력

출력

제한

예제 입력 1

10
8
3
2
15

예제 출력 1

7
7

예제 입력 2

8
7
2
2
27

예제 출력 2

5
2

예제 입력 3

8
7
2
2
40

예제 출력 3

7
4

예제 입력 4

6
6
1
2
1

예제 출력 4

3
1

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2005 > CCC 2005 Junior Division 4번

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

출처

대학교 대회

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

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