#abc281h. Ex - Alchemy
Ex - Alchemy
Score : points
问题陈述
Takahashi 拥有 种类型的等级为 的宝石,每种各有 颗。
对于大于等于 的整数 ,他可以将满足以下所有条件的 颗宝石放入炼金釜中,以换取一颗等级为 的宝石。
- 没有两颗宝石是同一种类。
- 每颗宝石的等级都小于 。
- 对于每个大于等于 的整数 ,最多只有一颗等级为 的宝石。
求 Takahashi 可以获得的不同种类的等级为 的宝石的数量,结果对 取模。
这里,任意两颗等级为 或更高的宝石被认为是同一种类,当且仅当它们是由同一组宝石生成的。
- 两组宝石被区分,当且仅当其中一组存在至少一颗宝石,而另一组不存在同类宝石。
任何等级为 的宝石和任何等级为 或更高的宝石都被认为是不同种类的。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi has kinds of level- gems, and gems of each of those kinds.
For an integer greater than or equal to , he can put gems that satisfy all of the following conditions into a cauldron to generate a level- gem in return.
- No two gems are of the same kind.
- Every gem's level is less than .
- For every integer greater than or equal to , there is at most one level- gem.
Find the number of kinds of level- gems that Takahashi can obtain, modulo .
Here, two level- or higher gems are considered to be of the same kind if and only if they are generated from the same set of gems.
- Two sets of gems are distinguished if and only if there is a gem in one of those sets such that the other set does not contain a gem of the same kind.
Any level- gem and any level- or higher gem are of different kinds.
Constraints
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 3
Sample Output 1
10
Here are ten ways to obtain a level- gem.
- Put three kinds of level- gems into the cauldron.
- Takahashi has three kinds of level- gems, so there is one way to choose three kinds of level- gems. Thus, he can obtain one kind of level- gem in this way.
- Put one kind of level- gem and two kinds of level- gems into the cauldron.
- A level- gem can be obtained by putting two kinds of level- gems into the cauldron.
- Takahashi has three kinds of level- gems, so there are three ways to choose two kinds of level- gems. Thus, three kinds of level- gems are available here.
- There are three kinds of level- gems, and three ways to choose two kinds of level- gems, so he can obtain kinds of level- gems in this way.
- A level- gem can be obtained by putting two kinds of level- gems into the cauldron.
Sample Input 2
1 100
Sample Output 2
100
Sample Input 3
200000 1000000000
Sample Output 3
797585162
update @ 2024/3/10 11:49:20