您的位置:首页 > 大数据 > 人工智能

Ural 1017 Staircases(DP)

2014-10-05 10:51 225 查看
题目地址:Ural 1017

简单的背包。

代码如下:

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
const int INF=0x3f3f3f3f;
#define LL long long
LL dp[60006];
int main()
{
int i, j, n;
memset(dp,0,sizeof(dp));
dp[0]=1;
for(i=1;i<=500;i++)
{
for(j=500;j>=i;j--)
{
dp[j]+=dp[j-i];
}
}
while(scanf("%d",&n)!=EOF)
{
printf("%lld\n",dp
-1);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ACM c语言 算法 编程 DP