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

6096번 - Bulls and Cows 다국어

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

문제

Farmer John wants to position N (1 <= N <= 100,000) cows and bulls in a single row to present at the annual fair.

FJ has observed that the bulls have been quite pugnacious lately; if two bulls too close together in the line, they will argue and begin to fight, ruining the presentation. Ever resourceful, FJ calculated that any two bulls must have at least K (0 <= K < N) cows between them in order to avoid a fight.

FJ would like you to help him by counting the number of possible sequences of N bulls and cows that avoid any fighting. FJ considers all bulls the to be the same and all cows to be the same; thus, two sequences are only different if they have different kinds of cattle in some position.

입력

  • Line 1: Two space-separated integers: N and K

출력

  • Line 1: A single integer representing the number of ways FJ could create such a sequence of cattle. Since this number can be quite large, output the result modulo 5,000,011.

제한

예제 입력 1

4 2

예제 출력 1

6

힌트

The following are the six possible sequences FJ could create (note that 'C' stands for cow and 'B' stands for bull):

CCCC
BCCC
CBCC
CCBC
CCCB
BCCB

출처

Olympiad > USA Computing Olympiad > 2008-2009 Season > USACO February 2009 Contest > Silver 3번

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

출처

대학교 대회

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

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