#arc104d. [arc104_d]Multiset Mean
[arc104_d]Multiset Mean
Problem Statement
Given positive integers and , solve the following problem for every integer between and (inclusive):
- Find the number, modulo , of non-empty multisets containing between and (inclusive) instances of each of the integers such that the average of the elements is .
Constraints
- is prime.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Use the following format:
Here, should be the number, modulo , of multisets such that the average of the elements is .
Sample Input 1
3 1 998244353
Sample Output 1
1
3
1
Consider non-empty multisets containing between and instance(s) of each of the integers between and . Among them, there are:
- one multiset such that the average of the elements is : ;
- three multisets such that the average of the elements is : ;
- one multiset such that the average of the elements is : .
Sample Input 2
1 2 1000000007
Sample Output 2
2
Consider non-empty multisets containing between and instances of each of the integers between and . Among them, there are:
- two multisets such that the average of the elements is : .
Sample Input 3
10 8 861271909
Sample Output 3
8
602
81827
4054238
41331779
41331779
4054238
81827
602
8