CF118D.Caesar's Legions

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Gaius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had _n_1 footmen and _n_2 horsemen. Caesar thought that an arrangement is not beautiful if somewhere in the line there are strictly more that _k_1 footmen standing successively one after another, or there are strictly more than _k_2 horsemen standing successively one after another. Find the number of beautiful arrangements of the soldiers.

Note that all _n_1 + _n_2 warriors should be present at each arrangement. All footmen are considered indistinguishable among themselves. Similarly, all horsemen are considered indistinguishable among themselves.

著名将领盖乌斯·尤利乌斯·凯撒热衷于排列他的士兵。整支军队共有 n1n_1 名步兵和 n2n_2 名骑兵。凯撒认为,若在队列中某处连续出现严格多于 k1k_1 名步兵,或连续出现严格多于 k2k_2 名骑兵,则该排列不美观。求所有美观的士兵排列数目。

注意:每种排列都必须包含全部 n1+n2n_1 + n_2 名战士。所有步兵彼此不可区分;同理,所有骑兵也彼此不可区分。

输入格式

The only line contains four space-separated integers _n_1, _n_2, _k_1, _k_2 (1 ≤ _n_1, _n_2 ≤ 100, 1 ≤ _k_1, _k_2 ≤ 10) which represent how many footmen and horsemen there are and the largest acceptable number of footmen and horsemen standing in succession, correspondingly.

唯一的一行包含四个以空格分隔的整数 n1n_1、n2n_2、k1k_1、k2k_2(1 ≤ n1, n2 ≤ 1001 ≤ n_1, n_2 ≤ 100,1 ≤ k1, k2 ≤ 101 ≤ k_1, k_2 ≤ 10),分别表示步兵和骑兵的数量,以及允许连续站立的最大步兵数和最大骑兵数。

输出格式

Print the number of beautiful arrangements of the army modulo 100000000 (108). That is, print the number of such ways to line up the soldiers, that no more than _k_1 footmen stand successively, and no more than _k_2 horsemen stand successively.

输出军队的优美排列数对 100000000100000000(即 10810^8)取模的结果。也就是说,输出满足以下条件的士兵排队方式数目:至多有 k1k_1 个步兵连续排列,且至多有 k2k_2 个骑兵连续排列。

输入输出样例

  • 输入#1

    2 1 1 10

    输出#1

    1
  • 输入#2

    2 3 1 2

    输出#2

    5
  • 输入#3

    2 4 1 1

    输出#3

    0

说明/提示

Let's mark a footman as 1, and a horseman as 2.

In the first sample the only beautiful line-up is: 121

In the second sample 5 beautiful line-ups exist: 12122, 12212, 21212, 21221, 22121

我们将步兵标记为 1,骑兵标记为 2。

在第一个样例中,唯一的优美队列为:121

在第二个样例中,存在 5 种优美队列:12122、12212、21212、21221、22121

输入解题思路,AI测评打分。不知道怎么写?

首页