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

19169번 - Calendar 스페셜 저지다국어

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

문제

Handy Smurf created his newest invention: nanobot calendar. It obviously consists of nanobots showing current date. Every day in order to switch current date they have to perform a cyclic rotation by $k$ places (so that nanobot that was initially at position $i$ is now at position $(i+k) \bmod n,ドル nanobots are indexed from 0ドル$). However, nanobots can only understand one command: reverse $l r$ which reverses positions of all nanobots at positions between $l$ and $r$ (so that nanobot that was initially at position $l$ is now at $r,ドル the one that was at $l+1$ is now at $r-1$ and so on). Help Handy write an algorithm for updating the date with minimum number of commands issued.

입력

First and only line of input contains two integers $n$ and $k$ (1ドル \leq n \leq 10^9,ドル 0ドル \leq k < n$), specifying the number of nanobots and number of places to rotate.

출력

First line of output should contain integer $m$ -- the number of reverse commands used. On each of the next $m$ lines output two integers $a$ and $b$ (0ドル \leq a \leq b < n$) which means that the next command is reverse $a b$.

제한

예제 입력 1

2 1

예제 출력 1

1
0 1

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2015 > Day 5: U of Wroclaw Contest C번

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

출처

대학교 대회

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

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