Jan is an eating machine. At this moment, he is in front of a table with different kinds of cakes. He wants to eat cake exactly times, but with two restrictions:
Every kind of cake must be tasted at least once.
He wants to repeat at least with half of the kinds of cakes.
Given and , can you compute the number of ways of eating cakes? The eating order matters. For instance, if there are three kinds of cakes, say A B and C, and Jan wants to eat cake six times, these are some of the 450 possibilities: AAABBC, ABABAC, AACCBB. Note that AAAABC is not an allowed combination.
Input consists of several cases, each with and . Assume , and that for each given combination there is at least one way of eating cake.
For every case, print the result modulo .
Author: Salvador Roura
Generation: 2026-01-25T11:50:51.646Z
© Jutge.org, 2006–2026.
https://jutge.org