#P7355. 「PMOI-1」抽奖
「PMOI-1」抽奖
Description
There are types of items in the event prize pool, and dead_X has redemption coupons. One coupon can be exchanged for one lottery chance or coins.
dead_X decides to use some coupons for the lottery, and exchange the remaining coupons for coins.
In one lottery chance, dead_X will obtain, with equal probability, a -second trial card of one item from the prize pool.
Because dead_X bought a VIP card in the event, after all lotteries are finished, he may choose one type of trial card obtained from the lotteries, submit all trial cards of that type, and receive the corresponding type of permanent item.
Note that dead_X may choose not to use this feature, but he cannot use it more than once.
dead_X, who has trouble making choices, wants to know how many possible event outcomes there are.
Two event outcomes are different if and only if the coins obtained are different, or the trial card obtained in any lottery is different (i.e., the sequence of drawn trial cards is different), or the permanent item obtained is different.
Note that the lottery only gives trial cards. The final chosen permanent item is unrelated to which draw each trial card came from.
Update 2023.11.16: The problem setter could not stand the statement written years ago, so here is a formal statement.
Define the weight of a sequence as the number of distinct elements in it . For example, the weight of is .
For all integer sequences whose length and each number , compute the sum of their weights modulo .
Input Format
This problem has multiple test cases.
The first line contains an integer , the number of test cases.
For each test case, input two positive integers , representing the number of item types and the number of redemption coupons.
Output Format
Output lines in total. Each line contains one positive integer, the number of outcomes modulo .
5
2 1
2 2
3 3
114 514
1919810 7872754
5
15
115
338602801
30498159
Hint
[Sample Explanation]
The following are all possible outcomes for the second test case:
Assume the two items are and .
- Exchange for coins.
- Exchange for coins, obtain an trial card.
- Exchange for coins, obtain a trial card.
- Exchange for coins, obtain an permanent item.
- Exchange for coins, obtain a permanent item.
- First obtain an trial card, second obtain an trial card.
- First obtain an trial card, second obtain a trial card.
- First obtain a trial card, second obtain an trial card.
- First obtain a trial card, second obtain a trial card.
- First obtain an trial card, second obtain an trial card, designate as the permanent item.
- First obtain an trial card, second obtain a trial card, designate as the permanent item.
- First obtain a trial card, second obtain an trial card, designate as the permanent item.
- First obtain an trial card, second obtain a trial card, designate as the permanent item.
- First obtain a trial card, second obtain an trial card, designate as the permanent item.
- First obtain a trial card, second obtain a trial card, designate as the permanent item.
[Constraints]
- Subtask 1 (10 pts): .
- Subtask 2 (10 pts): .
- Subtask 3 (10 pts): .
- Subtask 4 (20 pts): .
- Subtask 5 (20 pts): .
- Subtask 6 (30 pts): no special restrictions.
For of the testdata, and .
Translated by ChatGPT 5
京公网安备 11011102002149号