本文共 1909 字,大约阅读时间需要 6 分钟。
1126
413
#include#include #include using namespace std;int dp[500][500];int main() { int n,m,i,k,j,h,sum; int c[]={0,1,5,10,25,50}; while(cin>>h) { memset(dp,0,sizeof(dp)); dp[0][0]=1; for(i=1;i<=5;i++) { for(k=1;k<=100;k++)//因为不能超过100枚 所以需要二维数组 { for(j=c[i];j<=h;j++) { dp[k][j]+=dp[k-1][j-c[i]]; } } } sum=0; for(i=0;i<=100;i++) { sum+=dp[i][h]; } cout< <
转载地址:http://wxfci.baihongyu.com/