每个物品选一次 01背包
#include <cstdio> #include <cstring> const int maxn = 510; double dp[maxn]; int main() { memset(dp, 0 ,sizeof(dp)); dp[0] = 1; for(int i = 1; i <= 500; i++) { for(int j = 500; j >= i; j--) { dp[j] += dp[j-i]; } } int n; while(scanf("%d", &n) && n) { printf("%.0f\n", dp[n]-1); } return 0; }
ZOJ 1163 The Staircases / 01背包,布布扣,bubuko.com
ZOJ 1163 The Staircases / 01背包
原文:http://blog.csdn.net/u011686226/article/details/22590147