Amplitude Hackathon Winter '24 Problem 8 - Hot Ones

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 2.0s
Memory limit: 1G

Problem type

Hot Ones - the show with hot questions and even hotter wings...

2^n-1 people participated in the latest iteration of Hot Ones at Amplitude. There were n sauces and everyone got a raffle ticket for every sauce they successfully tried, and the winner will get all of the Hot Ones sauces to enjoy!

The n sauces each have unique integral kilo-Scoville heat unit values from 1 to n. Each individual will eat the sauces in increasing order of kilo-Scoville heat units.

Unfortunately, due to the popularity of Hot Ones, some individuals were not able to try out every sauce. For every possible subset of sauces, exactly one person tried that exact subset of sauces.

Because no one wanted to be the first to go grab the ice cream, everyone waited until the very end of the event to go eat ice cream. The number of litres of ice cream a person ate was exactly equal to their maximum spice jump.

The maximum spice jump of a person is equal to the maximum increase in kilo-Scoville heat units between consecutive sauces. We assume for simplicity that everyone started out trying a 0 kilo-Scoville sauce.

The workplace team wants to ensure that they purchase enough ice cream for everyone, but not so much that they have melted ice cream leftover to deal with.

Constraints

1 \le n \le 5 \cdot 10^3

Input Specification

The first and only line of input contains a single integer, n.

Output Specification

Let l be the number of litres of ice cream the workplace team must buy. Output the remainder when l is divided by 998244353.

Sample Input 1

3

Sample Output 1

12

Sample Explanation 1

There are 7 people who participated. Their maximum spice levels are as follows:

  • Person 1 tried only sauce 1 and had a maximum spice jump of 1.
  • Person 2 tried only sauce 2 and had a maximum spice jump of 2.
  • Person 3 tried sauces 1 and 2 and had a maximum spice jump of 1.
  • Person 4 tried only sauce 3 and had a maximum spice jump of 3.
  • Person 5 tried sauces 1 and 3 and had a maximum spice jump of 2.
  • Person 6 tried sauces 2 and 3 and had a maximum spice jump of 2.
  • Person 7 tried sauces 1, 2, and 3, and had a maximum spice jump of 1.

In total, they eat 1 + 2 + 1 + 3 + 2 + 2 + 1 = 12 litres of ice cream.

Sample Input 2

28

Sample Output 2

367691381

Sample Explanation 2

We can show that the number of litres of ice cream eaten in this scenario is 1365935734. The remainder when 1365935734 is divided by 998244353 is 367691381.


Comments

There are no comments at the moment.