#ABC159F. [ABC159F] Knapsack for All Segments
[ABC159F] Knapsack for All Segments
No testdata at current.
No submission language available for this problem.
Score : points
Problem Statement
Given are a sequence of integers , , , and a positive integer . For a pair of integers such that , let us define as follows:
- is the number of sequences of integers such that and .
Find the sum of over all pairs of integers such that . Since this sum can be enormous, print it modulo .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the sum of , modulo .
3 4
2 2 4
5
The value of for each pair is as follows, for a total of .
- (for the sequence )
- (for and )
- (for )
- (for )
5 8
9 9 9 9 9
0
10 10
3 1 4 1 5 9 2 6 5 3
152