CF768F.Barrels and boxes

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Tarly has two different type of items, food boxes and wine barrels. There are f food boxes and w wine barrels. Tarly stores them in various stacks and each stack can consist of either food boxes or wine barrels but not both. The stacks are placed in a line such that no two stacks of food boxes are together and no two stacks of wine barrels are together.

The height of a stack is defined as the number of items in the stack. Two stacks are considered different if either their heights are different or one of them contains food and other contains wine.

Jon Snow doesn't like an arrangement if any stack of wine barrels has height less than or equal to h. What is the probability that Jon Snow will like the arrangement if all arrangement are equiprobably?

Two arrangement of stacks are considered different if exists such i, that i-th stack of one arrangement is different from the i-th stack of the other arrangement.

塔利有两种不同的物品:食物箱和酒桶。共有 ff 个食物箱和 ww 个酒桶。塔利将它们存放在若干堆栈中,每堆栈仅由食物箱或仅由酒桶组成(不能混放)。这些堆栈排成一行,且任意两个食物箱堆栈不能相邻,任意两个酒桶堆栈也不能相邻。

堆栈的高度定义为该堆栈中物品的数量。若两个堆栈高度不同,或其中一个装食物、另一个装酒,则认为这两个堆栈不同。

琼·雪诺不喜欢某种堆栈排列方式,当且仅当其中存在某个酒桶堆栈,其高度小于或等于 hh。假设所有合法的堆栈排列方式等概率出现,求琼·雪诺喜欢该排列方式的概率。

若存在某个下标 ii,使得一种排列方式的第 ii 个堆栈与另一种排列方式的第 ii 个堆栈不同,则认为这两种堆栈排列方式不同。

输入格式

The first line of input contains three integers f, w, h (0 ≤ f, w, h ≤ 105) — number of food boxes, number of wine barrels and h is as described above. It is guaranteed that he has at least one food box or at least one wine barrel.

输入的第一行包含三个整数 ff、ww、hh(0 ≤ f, w, h ≤ 1050 \leq f,\,w,\,h \leq 10^5),分别表示食物箱的数量、酒桶的数量,以及上述定义的 hh。保证他至少有一个食物箱或至少有一个酒桶。

输出格式

Output the probability that Jon Snow will like the arrangement. The probability is of the form , then you need to output a single integer p·q - 1 mod (109 + 7).

输出琼恩·雪诺喜欢该排列的概率。该概率形如 ,此时你需要输出一个整数 $ p \cdot q^{-1} \bmod (10^9 + 7) $。

输入输出样例

  • 输入#1

    1 1 1

    输出#1

    0
  • 输入#2

    1 2 1

    输出#2

    666666672

说明/提示

In the first example f  =  1, w = 1 and h = 1, there are only two possible arrangement of stacks and Jon Snow doesn't like any of them.

In the second example f = 1, w = 2 and h = 1, there are three arrangements. Jon Snow likes the (1) and (3) arrangement. So the probabilty is .

在第一个例子中,f=1f = 1,w=2w = 2,h=1h = 1,仅有两种可能的堆叠方式,而琼恩·雪诺不喜欢其中任何一种。

在第二个例子中,f=1f = 1,w=2w = 2,h=1h = 1,共有三种堆叠方式。琼恩·雪诺喜欢第(1)种和第(3)种堆叠方式。因此概率为 。

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

首页