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

22651번 - Riffle Swap 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 (추가 시간 없음) 512 MB1311888.889%

문제

You have a deck of 2N cards (1 ≤ N ≤ 1000000) and want to have them shuffled.

The most popular shuffling technique is probably the riffle shuffle, in which you split a deck into two halves, place them in your left and right hands, and then interleave the cards alternatively from those hands. The shuffle is called perfect when the deck is divided exactly in half and the cards are interleaved one-by-one from the bottom half. For example, the perfect riffle shuffle of a deck of eight cards <0, 1, 2, 3, 4, 5, 6, 7> will result in a deck <0, 4, 1, 5, 2, 6, 3, 7>.

Since you are not so good at shuffling that you can perform the perfect riffle shuffle, you have decided to simulate the shuffle by swapping two cards as many times as needed. How many times you will have to perform swapping at least? As the resultant number will obviously become quite huge, your program should report the number modulo M = 1000003.

입력

The input just contains a single integer N.

출력

Print the number of swaps in a line. No extra space or empty line should occur.

제한

예제 입력 1

1

예제 출력 1

0

예제 입력 2

2

예제 출력 2

1

예제 입력 3

3

예제 출력 3

4

예제 입력 4

4

예제 출력 4

10

예제 입력 5

10

예제 출력 5

916

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Winter Camp > JAG Winter Camp 2009 Day 3 G번

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

출처

대학교 대회

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

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