#P6191. [USACO09FEB] Bulls And Cows S

    ID: 6966 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>数学递推2009USACO组合数学前缀和

[USACO09FEB] Bulls And Cows S

Background

The annual fair is coming. Farmer John wants to arrange NN (1N1051 \leq N \leq 10^5) cows and bulls in a single line. John has noticed that the bulls have been very aggressive lately; if two bulls are too close in the line, they will argue and end up fighting, ruining the peaceful atmosphere.

Problem Description

John is very resourceful. He has determined that there must be at least KK (0K<N0 \leq K \lt N) cows between any two bulls in order to avoid fights. John wants you to help him calculate how many different arrangements can avoid any fighting. John considers all bulls identical and all cows identical. Therefore, as long as the positions of different types of cattle are different, the arrangements are considered different.

Input Format

Two integers NN and KK.

Output Format

Output the number of ways John can arrange them. Since this number may be very large, output the result modulo 50000115\,000\,011.

4 2
6

Hint

Below are the 6 feasible arrangements that FJ came up with (CC stands for cow, BB stands for bull).

  • CCCC
  • BCCC
  • CBCC
  • CCBC
  • CCCB
  • BCCB

Translated by ChatGPT 5