atcoder#ABC284G. [ABC284G] Only Once
[ABC284G] Only Once
Score : points
Problem Statement
For a sequence of length , , consisting of integers between and , inclusive, and an integer , let us define a sequence of length , , as follows.
- .
- .
Additionally, let us define as the number of distinct integers that occur exactly once in the sequence . More formally, is the number of values such that exactly one index satisfies .
You are given an integer . There are sequences that can be . Find the sum of over all of them, modulo .
Constraints
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
4 100000000
624
As an example, let us consider the case .
- For : we have , where two integers, and , occur exactly once, so .
- For : we have , where one integer, , occurs exactly once, so .
- For : we have , where no integers occur exactly once, so .
- For : we have , where no integers occur exactly once, so .
Thus, we have .
If we similarly compute for the other sequences, the sum of this value over all sequences is .
7 1000000000
5817084
2023 998244353
737481389
Print the sum modulo .
100000 353442899
271798911