Mock CCC '23 1 S3 - Richard The Penguin

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 0.25s
PyPy 3 0.5s
Memory limit: 1G

Problem type

Richard is a penguin who regularly commutes between Canada and the United States.

Specifically, Canada is at location 1, and the United States is at location N. In locations 2 through N-1, there are ice blocks that Richard can jump on. Richard can jump from location i to location j if and only if |i - j| \le K.

Richard does not believe in wasting time, so when he is commuting in one direction, he will always move in that direction. This means that when commuting from Canada to the United States, locations are monotonically increasing in number, and when commuting from the United States to Canada, locations are monotonically decreasing in number.

Richard's commute is complicated during the fall and spring when the ice is thawing between Canada and the United States. If Richard jumps on an ice block, that ice block will melt enough that it will not be usable on the return journey.

Count the number of distinct ways that Richard can do a round-trip commute from Canada to the United States and back. Two ways are distinct if, in some direction, Richard uses an ice block travelling in that direction in one way but not in the other way.

Constraints

2 \le N \le 5 \cdot 10^3

1 \le K < N

In tests worth 1 mark, N \le 50 and K \le 2.

In tests worth an additional 2 marks, N \le 50 and either K \le 2 or K = N-1.

In tests worth an additional 3 marks, N \le 50.

In tests worth an additional 4 marks, N \le 500.

In tests worth an additional 4 marks, N \le 2500.

Input Specification

The first and only line contains two integers, N and K.

Output Specification

Let W be the number of ways Richard can commute. Output W modulo 998244353.

Sample Input

5 3

Sample Output

12

Comments

There are no comments at the moment.