atcoder#AGC039F. [AGC039F] Min Product Sum
[AGC039F] Min Product Sum
Score : points
Problem Statement
For each of the ways to write an integer between and (inclusive) in every square in a square grid with rows and columns, find the value defined below, then compute the sum of all those values, modulo .
- For each of the squares, find the minimum among the integers written in the square's row or the square's column. The value defined for the grid is the product of all these values.
Constraints
- and are integers.
- is prime.
Input
Input is given from Standard Input in the following format:
Output
Print the sum of the values, modulo .
2 2 2 998244353
35
We have way to write integers such that the product of the values is , ways such that the product is , and ways such that the product is .
2 3 4 998244353
127090
31 41 59 998244353
827794103