It's a little different from the template. The number of coins here has to be changed.
[Csharp]
# Include "stdio. h"
Int main ()
{
Int c1 [8005], c2 [8005], num [3], coin [3] = {, 5 };
Int I, j, k, sum;
While (scanf ("% d", & num [0], & num [1], & num [2])! = EOF)
{
If (! Num [0] &! Num [1] &! Num [2]) break;
If (num [0] = 0)
{
Printf ("1 \ n"); continue;
}
Sum = num [0] + 2 * num [1] + 5 * num [2];
For (I = 0; I <= 8000; I ++)
C1 [I] = c2 [I] = 0;
For (I = 0; I <= num [0]; I ++)
C1 [I] = 1;
For (I = 1; I <= 2; I ++)
{
For (j = 0; j <= sum; j ++)
{// The number of coins k has a range, so you cannot use the template method (for (k = 0; k + j <= sum; k + = coin [I]).
For (k = 0; k * coin [I] + j <= sum & k <= num [I]; k ++)
C2 [j + k * coin [I] + = c1 [j];
}
For (j = 0; j <= sum; j ++)
{
C1 [j] = c2 [j]; c2 [j] = 0;
}
}
For (I = 1; I <= 8000; I ++)
{
If (c1 [I] = 0) break;
}
Printf ("% d \ n", I );
}
Return 0;
}
Author: yyf572132811