阅读背景:

357 - Let Me Count The Ways---水题--数据类型long long

来源:互联网 
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<set>
#include<cstring>
#include <algorithm>
#define inf 0x7fffffff
#define N 30005
#define MIN 1e-11
#define M 10000
#define LL long long
using namespace std;
int n,k,h,t,m;
int my[6]= {0,1,5,10,25,50};
LL a[N];
void print(int a[],int n)
{
    cout<<a[0];
    for(int i=1; i<n; ++i)
        cout<<" "<<a[i];
    cout<<endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("ex.in","r",stdin);
#endif
//    scanf("%d%*c%*c",&t);
    while(scanf("%d",&m)!=EOF)
    {
//        memset(a,0,sizeof(a));

        for(int i=0; i<=m; i++)
            a[i]=1;

        for(int i=2; i<=5; i++)
        {
//            a[my[i]]++;
            for(int j=my[i]; j<=m; j++)
            {
                a[j]+=a[j-my[i]];
            }
//            print(a,m+1);
        }
        if(a[m]==1)
        printf("There is only 1 way to produce %d cents change.\n",m);
        else
        printf("There are %lld ways to produce %d cents change.\n",a[m],m);

    }
    return 0;
}
#include<cstdlib>
#include<iostream>
#include<c



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: