Four Elements
Time limit2sMemory limit512 MB
Count the 4-element subsets of a union of n disjoint integer ranges whose sum equals s, modulo 998244353.
- Level
Hard9 of 10
- Topics
- Math, Combinatorics, Intervals, Dynamic programming
- Solved
- No attempts yet
Problem
Set is the union of ranges . How many 4-element subsets of have a sum equal to ? Print the count modulo 998 244 353.
Input
The first line contains two integers and (, ). Each of the next lines contains two integers and , the bounds of the -th range (, ).
Output
Print the number of 4-element subsets of with sum , modulo 998 244 353.
Hint
In the example, . The 4-element subsets with sum 17 are , , , and .