分析:计算背包方案数目,需要注意输出的格式,还有要使用long long类型数据
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int cur[]={0,10000,5000,2000,1000,500,200,100,50,20,10,5};
long long dp[30010];
int main()
{
double amount;
int V;
while (scanf("%lf",&amount)!=EOF)
{
if(amount*100==0) break;
V=amount*100+0.5f;
memset(dp,0,sizeof(dp));
dp[0]=1;
for(int i=1;i<=11;i++)
for(int j=cur[i];j<=V;j++)
dp[j]=dp[j]+dp[j-cur[i]];
printf("%6.2lf%17lld ",amount,dp[V]);
}
return 0;
}
#include<cstdlib>
#include<cstring>
using namespace std;
int cur[]={0,10000,5000,2000,1000,500,200,100,50,20,10,5};
long long dp[30010];
int main()
{
double amount;
int V;
while (scanf("%lf",&amount)!=EOF)
{
if(amount*100==0) break;
V=amount*100+0.5f;
memset(dp,0,sizeof(dp));
dp[0]=1;
for(int i=1;i<=11;i++)
for(int j=cur[i];j<=V;j++)
dp[j]=dp[j]+dp[j-cur[i]];
printf("%6.2lf%17lld ",amount,dp[V]);
}
return 0;
}