#P2592. [ZJOI2008] 生日聚会

    ID: 1605 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划,dp数学递推2008各省省选浙江

[ZJOI2008] 生日聚会

Description

Today is hidadz’s birthday, and she has invited many friends to her birthday party. hidadz takes her friends to the garden, planning to sit in a row to play a game. To keep the game from being boring, the seating arrangement must satisfy the following condition:

For any consecutive segment, the absolute difference between the number of boys and the number of girls does not exceed kk.

Soon, the kids find one such arrangement and start the game. hidadz’s good friend Susie notices that there are actually many such seating arrangements, so since everyone can quickly find one, how many are there in total? The math-loving hidadz and her friends begin to think about this question.

Assume there are nn boys and mm girls at the party. Can you answer Susie and hidadz’s question? Since this number can be large, they only want the remainder when it is divided by 1234567812345678.

Input Format

The input contains a single line with 33 integers: the number of boys nn, the number of girls mm, and the constant kk.

Output Format

Output a single line containing the required answer.

1 2 1
1

Hint

For 30%30\% of the testdata, n,m20n, m \le 20.

For 100%100\% of the testdata, n,m150n, m \le 150, k20k \le 20.

Translated by ChatGPT 5