QOJ.ac

QOJ

Limite de temps : 3.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#8942. 糖果甜 3

Statistiques

Pibi、Prof. Peng 和 Emperor Bie 正在玩一个游戏。三名玩家持有三种不同类型的卡牌。Pibi 持有 $A$ 张 1 类卡牌,Prof. Peng 持有 $B$ 张 2 类卡牌,Emperor Bie 持有 $C$ 张 3 类卡牌。三名玩家使用一个初始为空的卡牌堆进行游戏。

游戏持续 $A + B + C$ 轮,在每一轮中:

  • 一名至少还剩 1 张卡牌的玩家打出他的一张卡牌。
  • 如果卡牌堆为空,或者卡牌堆中所有的卡牌与他打出的卡牌类型相同,则该玩家将这张卡牌放入卡牌堆。
  • 否则,他从卡牌堆中取走一张卡牌并将其丢弃,同时丢弃他刚刚打出的那张卡牌。

例如,假设 Pibi 持有 1 张 1 类卡牌,Prof. Peng 持有 3 张 2 类卡牌,Emperor Bie 持有 2 张 3 类卡牌。玩家打出卡牌的顺序为 [Pibi, Prof. Peng, Prof. Peng, Emperor Bie, Emperor Bie, Prof. Peng]。每一轮后卡牌堆中的卡牌为:

第一轮后:[1](Pibi 将他的卡牌放入卡牌堆) 第二轮后:[](Prof. Peng 打出他的卡牌,并从卡牌堆中取走一张卡牌丢弃,同时丢弃他打出的卡牌) 第三轮后:[2](Prof. Peng 将他的卡牌放入卡牌堆) 第四轮后:[](Emperor Bie 打出他的卡牌,并从卡牌堆中取走一张卡牌丢弃,同时丢弃他打出的卡牌) 第五轮后:[3](Emperor Bie 将他的卡牌放入卡牌堆) 第六轮后:[](Prof. Peng 打出他的卡牌,并从卡牌堆中取走一张卡牌丢弃,同时丢弃他打出的卡牌)

现在,假设有 $m$ 个时刻卡牌堆为空,且在最后一轮结束时卡牌堆为空。形式化地,存在一个列表 $t_1, t_2 \dots t_m$ ($1 \le t_1 < t_2 \dots < t_m = A + B + C$),包含所有使得第 $t_i$ 轮($1 \le i \le m$)结束后卡牌堆为空的整数 $t_i$。三名玩家将获得 $m^x$ 袋糖果。这里,$x$ 是游戏开始前确定的常数。如果游戏结束后卡牌堆不为空,则三名玩家将无法获得任何糖果。

现在三名玩家想知道,在所有可能的游戏中,他们能获得的糖果总数是多少。当且仅当存在某个 $i$,使得第 $i$ 轮打出卡牌的玩家不同时,两场游戏被视为不同。输出结果对 $10^9 + 7$ 取模。

输入格式

仅一行,包含四个整数 $A, B, C, x$ ($1 \le A, B, C \le 1000, 1 \le A + B + C \le 1000, 1 \le x \le 10^9$),分别表示 Pibi 手中的卡牌数量、Prof. Peng 手中的卡牌数量以及 Emperor Bie 手中的卡牌数量。

输出格式

输出一个整数,表示在所有可能的游戏中获得的糖果总数,对 $10^9 + 7$ 取模。

样例

输入 1

1 2 3 1

输出 1

110

输入 2

4 5 7 12

输出 2

881078346

说明

对于第一个样例,有 6 种可能的有效游戏满足 $m = 1$,16 种可能的有效游戏满足 $m = 2$,以及 24 种可能的有效游戏满足 $m = 3$,因此答案为 $6 \times 1^1 + 16 \times 2^1 + 24 \times 3^1 = 110$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.