atcoder#ABC281H. [ABC281Ex] Alchemy
[ABC281Ex] Alchemy
Score : points
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.
3 3
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.
- 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.
- 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.
1 100
100
200000 1000000000
797585162