当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6279:Circular Coloring

题目描述
Bobo considers $(n + m)$ balls arranged in a circle.
The balls are numbered with $0, 1, \dots, (n + m - 1)$ where the ball $i$ and the ball $(i + 1) \bmod (n + m)$ are adjacent.

Bobo would like to color $n$ of his balls black and $m$ of his balls white.
Bobo groups adjacent balls with same colors, and he determines the weight of the coloring as the product of the lengths of groups.

He would like to know the sum of the weight of the possible colorings, modulo $(10^9+7)$.
输入解释
The input consists of several test cases and is terminated by end-of-file.

Each test case contains two integers $n$ and $m$.
输出解释
For each test case, print an integer which denotes the result.

## Constraint

* $1 \leq n, m \leq 5000$
* The number of test cases does not exceed $5000$.
输入样例
1 2
2 3
5000 5000
输出样例
6
40
975597525

提示

For the second sample, there are $10$ possible colorings (listed below).
The number followed is the corresponding weight.

* `BBWWW` ($6$)
* `BWBWW` ($2$)
* `BWWBW` ($2$)
* `BWWWB` ($6$)
* `WBBWW` ($6$)
* `WBWBW` ($2$)
* `WBWWB` ($2$)
* `WWBBW` ($6$)
* `WWBWB` ($2$)
* `WWWBB` ($6$)

来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6279

最后修改于 2020-10-25T23:29:55+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 132768/132768K(Java/Others)