Classical Summation Problem
Time limit2sMemory limit1024 MB
Sum the smallest optimal city (the median of the friends' positions) over all n^k placements of k friends on a line of n cities, modulo 998244353.
- Level
Medium7 of 10
- Topics
- Combinatorics, Math
- Solved
- No attempts yet
Problem
The Republic of Never has cities and roads. The cities are numbered from to . The roads are numbered from to , and road connects cities and . Every road can be traversed in both directions. The distance is the smallest number of roads one needs to use to move from city to city .
friends want to meet. The -th friend lives in city . The friends choose a city that minimizes . If several cities achieve the minimum, they choose the one with the smallest number.
You know only the number of friends, not the cities where they live. Each friend can live in any of the cities, so there are possible cases. Find the sum of the numbers of the cities the friends choose over all cases.
Input
The only line contains two integers and , the number of cities and the number of friends ().
Output
Print the sum over all cases, modulo .
Hint
In the first case, there are 3 cities and 2 friends, so there are cases. If either friend lives in city 1, the friends choose city 1, which happens in 5 cases. Otherwise, if either friend lives in city 2, they choose city 2, which happens in 3 cases. In the remaining case, both friends live in city 3, and they choose city 3. The total is .