跟背包问题类似
看代码就够了
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
#include<iostream>
#include<cstring>
#include<string>
#include<iomanip>
#include<algorithm>
using namespace std;
const int N1 = 30000;
const int N2 = 11;
long long dp[N1 + 5][N2 + 5];
const int p[N2 + 1] = { 0,5,10,20,50,100,200,500,1000,2000,5000,10000 };
void init()
{
memset(dp, 0, sizeof(dp));
for (int i = 1; i <= N2; i++) dp[0][i] = 1;
for (int i = 5; i <= N1; i += 5) {
dp[i][1] = 1;
for (int j = 2; j <= N2; j++) {
dp[i][j] = dp[i][j - 1];
if (i >= p[j]) dp[i][j] += dp[i - p[j]][j];
}
}
}
int main()
{
init();
double n;
while (cin >> n && n != 0.0) {
printf("%6.2f", n);
cout.width(17);
cout << dp[int(n * 100 + 0.5)][N2] << endl;
}
}