mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 2069_cnblogs.cpp
From http://www.cnblogs.com/qiufeihai/archive/2012/09/11/2680840.html
This commit is contained in:
parent
94ffd5d482
commit
aefa23377a
44
HDOJ/2069_cnblogs.cpp
Normal file
44
HDOJ/2069_cnblogs.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
using namespace std;
|
||||
|
||||
const int M = 300 + 10;
|
||||
|
||||
int dp[111][M];
|
||||
int c[] = {0, 1, 5, 10, 25, 50};
|
||||
|
||||
int main()
|
||||
{
|
||||
//freopen("in.txt", "r", stdin);
|
||||
int n;
|
||||
while (~scanf("%d", &n))
|
||||
{
|
||||
|
||||
memset(dp, 0, sizeof(dp));
|
||||
dp[0][0] = 1;
|
||||
|
||||
for (int i = 1; i <= 5; i++)//枚举硬币总类
|
||||
{
|
||||
for (int num = 1; num <= 100; num++)//枚举硬币个数
|
||||
{
|
||||
for (int j = c[i]; j <= n; j++)//枚举容量
|
||||
{
|
||||
|
||||
dp[num][j] += dp[num - 1][j - c[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ans = 0;
|
||||
for (int i = 0; i <= 100; i++)//累加答案
|
||||
{
|
||||
ans += dp[i][n];
|
||||
}
|
||||
|
||||
printf("%d\n", ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user