No.215 Prime Dice and Composite Dice (3-Hard)
タグ : / 解いたユーザー数 32
作問者 :
LayCurse
Problem Statement
A prime die is a die whose faces have the integers \(2,3,5,7,11,13\) written on them.
A composite die is a die whose faces have the integers \(4,6,8,9,10,12\) written on them.
In a certain sugoroku game, you start from square \(0\), and you reach the goal upon arriving at square \(N\).
Each turn, you roll \(P\) prime dice and \(C\) composite dice. Letting \(x\) be the sum of the rolled values, if you are currently on square \(k\), you move to square \(\min(k+x, N)\).
Assuming that prime dice are indistinguishable from each other and composite dice are indistinguishable from each other, write a program that computes the number of patterns of ways to reach the goal, \({\rm mod}\ 1000000007\ (10^9+7)\).
Input
$N$ $P$ $C$
\(1 \leq N \leq 1000000000000000000 = 10^{18}\)
\(0 \leq P \leq 300\)
\(0 \leq C \leq 300\)
\(P + C \geq 1\)
Output
Output the number of patterns of ways to reach the goal, \({\rm mod}\ 1000000007\).
Print a newline after the output.
Sample
Sample 1
Input
1 1 1
Output
36
You can always reach the goal in \(1\) turn.
Depending on which value the prime die shows and which value the composite die shows, there are \(6 \times 6 = 36\) patterns.
Sample 2
Input
1 2 0
Output
21
As in Sample 1, you can always reach the goal in \(1\) turn.
However, since prime dice are indistinguishable, the rolls of the \(2\) prime dice form the \(21\) patterns \((2,2),(2,3),(2,5),(2,7),(2,11),(2,13),(3,3),(3,5),(3,7),(3,11),(3,13),(5,5),(5,7),(5,11),(5,13),(7,7),(7,11),(7,13),(11,11),(11,13),(13,13)\).
Sample 3
Input
5 2 0
Output
41
In the \(20\) cases where the first roll is not \((2,2)\), you can reach the goal in \(1\) turn.
If the first roll is \((2,2)\), it takes \(1\) more turn, and there are \(21\) patterns for the roll on turn \(2\).
Sample 4
Input
6 2 0
Output
61
In the \(19\) cases where the first roll is not one of \((2,2), (2,3)\), you can reach the goal in \(1\) turn.
If the first roll is one of \((2,2), (2,3)\), it takes \(1\) more turn, and there are \(21\) patterns each for the roll on turn \(2\).
Sample 5
Input
1 10 10
Output
9018009
You can always reach the goal in \(1\) turn, but the number of patterns of dice rolls is not that small.
Sample 6
Input
100000 8 12
Output
144097395
By the way, don't you think this problem ID has quite a nice flavor to it?
(Though $666$ would have been better.)
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。