# 钱币兑换问题

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8052    Accepted Submission(s): 4804

Problem Description

Input

Output

Sample Input
2934 12553

Sample Output
718831 13137761

Author
SmallBeer(CML)

Source

#include <iostream>
using namespace std;
const int _max = 40001;
// c1是保存各项质量砝码可以组合的数目
// c2是中间量，保存每一次的情况
int c1[_max], c2[_max];
int main()
{
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
//int n,i,j,k;
int nNum;   //
int i, j, k;
for(i=0; i<=32767; ++i)   // ---- ①
{
c1[i] = 1;
c2[i] = 0;
}
for(i=2; i<=3; ++i)   // ----- ②
{

for(j=0; j<=32767; ++j)   // ----- ③
for(k=0; k+j<=32767; k+=i)  // ---- ④
{
c2[j+k] += c1[j];
}
for(j=0; j<=32767; ++j)     // ---- ⑤
{
c1[j] = c2[j];
c2[j] = 0;
}
}
while(cin >> nNum)
{
cout << c1[nNum] << endl;
}
return 0;
}

#include<stdio.h>
int dp[35000];
int main(){
int i,j;
dp[0]=1;
for(i=1;i<=3;i++)
for(j=i;j<=35000;j++)
dp[j]+=dp[j-i];
int n;
while(scanf("%d",&n)!=EOF){
printf("%d\n",dp[n]);
}
return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int N;
int main()
{
while(~scanf("%d", &N))
{
int s = N/3+1;
for(int i = 0 ; i <= N/3 ; i++)
{
int t = (N-3*i)/2;
s += t;
}
printf("%d\n", s);
}
return 0;
}

• 本文已收录于以下专栏：

举报原因： 您举报文章：hdu 1284 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)