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

15167번 - Anticlockwise Motion 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB39302978.378%

문제

You have come up with an idea for a board game. The game is played on a board that is made up of 32 001 × 32 001 numbered squares. The centre square contains the number 1 and the other numbers are arranged in an anticlockwise spiral outwards (first moving downwards, then to the right, then upwards, then to the left, then downwards again, and so on). Figure A.1 displays the 5 × 5 squares in the middle of the board and Figure A.2 displays the 21 × 21 squares in the middle of the board for further clarification. When playing the game, players will only be able to move up, left, down and right. To help work out the rules for the game, you would like to know the shortest distance between two squares on the board using only these moves.

Figure A.1: The middle 25 squares.

입력

The input consists of a single line containing two integers a (1 ≤ a ≤ 109), which is the starting square, and b (1 ≤ b ≤ 109), which is the ending square.

출력

Display the shortest distance between a and b.

제한

예제 입력 1

12 2

예제 출력 1

2

예제 입력 2

16 24

예제 출력 2

6

힌트

Figure A.2: The middle 441 squares.

출처

ICPC > Regionals > South Pacific > South Pacific Region > 2016 ACM South Pacific Programming Contest A번

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

출처

대학교 대회

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

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