题目地址: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[n]-1);
}
return 0;
}