#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
using namespace std;
long long coin[]={1,5,10,25,50};
long long dp[6][30005],n,ar[30005];
long coinchange(long i,long make)
{
if(i==5)
{
if(make==0)
return 1;
else
return 0;
}
long long ret1=0,ret2=0;
if(dp[i][make]!=-1) return dp[i][make];
if(make-coin[i]>=0)
{
ret1=coinchange(i,make-coin[i]);
}
ret2=coinchange(i+1,make);
return dp[i][make]=ret1+ret2;
}
main()
{
memset(dp,-1,sizeof(dp));
for(long long i1=0;i1<=30000;i1++)
{
ar[i1]=coinchange(0,i1);
}
while(cin>>n)
{
cout<<ar[n]<<endl;
}
}
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
using namespace std;
long long coin[]={1,5,10,25,50};
long long dp[6][30005],n,ar[30005];
long coinchange(long i,long make)
{
if(i==5)
{
if(make==0)
return 1;
else
return 0;
}
long long ret1=0,ret2=0;
if(dp[i][make]!=-1) return dp[i][make];
if(make-coin[i]>=0)
{
ret1=coinchange(i,make-coin[i]);
}
ret2=coinchange(i+1,make);
return dp[i][make]=ret1+ret2;
}
main()
{
memset(dp,-1,sizeof(dp));
for(long long i1=0;i1<=30000;i1++)
{
ar[i1]=coinchange(0,i1);
}
while(cin>>n)
{
cout<<ar[n]<<endl;
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন