Uva_147
Count with DP, the state transition equation is f [I] [J] = sum {f [I] [J-K * A [I]} (J-K * A [I]> = 0, K is an integer), where I represents the I-th nominal value, j Represents the cents with J, and a [I] represents the size of the I-th nominal value. In recursive mode, a small nominal value is required for Recursive mode.
# Include <stdio. h>
# Include < String . H>
# Include <math. h>
# Define Maxd 6010
Int D [] = { 1 , 2 , 4 , 10 , 20 , 40 , 100 , 200 , 400 , 1000 , 2000 };
Long Long Int F [ 12 ] [Maxd];
Void Init ()
{
Int I, J, K;
Memset (F, 0 , Sizeof (F ));
For (I = 0 ; I <maxd; I ++)
F [ 0 ] [I] = 1 ;
For (I = 1 ; I < 11 ; I ++)
For (J = 0 ; J <maxd; j ++)
For (K = 0 ; K * d [I] <= J; k ++)
F [I] [J] + = f [I- 1 ] [J-K * d [I];
}
Void Solve ()
{
Int I, K;
Double A;
For (;;)
{
Scanf ( " % Lf " , & );
If (FABS (a) <1E- 9 )
Break ;
K = floor (* 100 + 0.5 )/ 5 ;
Printf ( " % 6.2f % 17lld \ n " , A, F [ 10 ] [K]);
}
}
Int Main ()
{
Init ();
Solve ();
Return 0 ;
}