357 - Let Me Count The Ways

来源:互联网 发布:易语言变速器源码 编辑:程序博客网 时间:2024/06/06 04:33
描述:这道题还好,相比起上一题没有精度问题#include <cstdio>long long s[30010];int v[6]= {1,5,10,25,50};void solve(){    s[0]=1;    for(int i=0; i<5; i++)        for(int j=v[i]; j<30010; j++)            s[j]+=s[j-v[i]];}int main(){    int n;    solve();   // freopen("a.txt","r",stdin);    while(scanf("%d",&n)!=EOF)    {        if(s[n]==1) printf("There is only 1 way to produce %d cents change.\n",n);        else printf("There are %lld ways to produce %d cents change.\n",s[n],n);    }    return 0;}

原创粉丝点击