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

25776번 - Pseudo Pseudo Random Numbers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB78654488.000%

문제

It turns out that if numbers were truly random, then each possible bit string (string of 0’s and 1’s) of length n would be equally likely. For example, 111111 would be just as likely as 010110 to occur. Unfortunately, most people believe that any time they see the same bit over and over again, that the process can't be truly random.

You are in charge of generating random bit strings of length n for use in a video game. However, the producer of the game has asked you to remove all possibilities where there are more than k 0’s or 1’s in a row. For example, if n = 4 and k = 2, then the 10 valid bit strings would be 0010, 0011, 0100, 0101, 0110, 1001, 1010, 1011, 1100, and 1101 (the other 6 strings of 4 bits either have more than two 0’s in a row or more than two 1’s in a row, so they are not valid).

Given the values of n and k, determine the number of n bit strings that do not contain any runs of 0’s or 1’s of length greater than k.

입력

There is only one input line; it contains two integers: n (2 ≤ n ≤ 20), indicating the length of the bit string for the problem, and k (1 ≤ k ≤ n), indicating the maximal length of a run of 0’s or 1’s for the bit strings to be created.

출력

Print the number of valid bit strings of length n that do not contain any runs of the same bit of length greater than k.

제한

예제 입력 1

4 2

예제 출력 1

10

예제 입력 2

5 1

예제 출력 2

2

예제 입력 3

20 20

예제 출력 3

1048576

힌트

출처

University > University of Central Florida > 2022 Local Programming Contest (Final Round) 4번

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

출처

대학교 대회

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

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