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

7107번 - Journey of A Knight 다국어

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

문제

The size of a right-angled cell board is n*m cells. The chess knight is located in the left bottom cell of the board (coordinates 1;1), as shown in pic.1.

The chess knight can move according to the chess rules - during each turn it can move according to the chess rules- either one cell in the vertical direction and one in horizontal or vice versa.

Thus, for example, if n=4 and m=3 and the knight is located in the cell (2;1) (see pic.2), then with the next turn it can move in any of the following cells : (1;3),(3;3) or (4;2).

For the given natural numbers n,m,i,j (n<=100,m<=100,i<=n,j<=m) given in the input your task is to determine and output, which is the least possible number of moves for the knight to reach the cell (i;j), starting from the cell (1;1).

If it is not possible to reach this cell, output one single word "NEVAR".

Pic. 1

Pic. 2

입력

출력

제한

예제 입력 1

5 3 1 2

예제 출력 1

3

예제 입력 2

100 2 2 2

예제 출력 2

NEVAR

힌트

출처

Olympiad > Latvian olympiad in informatics > 10th Latvian olympiad in informatics > Stage II (District/City) 2번

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

출처

대학교 대회

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

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