标签:
Description
Input
Output
Sample Input
3 20 20 20
Sample Output
3
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <queue> #include <vector> #include <iomanip> #include <math.h> #include <map> using namespace std; #define FIN freopen("input.txt","r",stdin); #define FOUT freopen("output.txt","w",stdout); #define INF 0x3f3f3f3f #define INFLL 0x3f3f3f3f3f3f3f #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 typedef long long LL; typedef pair<int,int> PII; int a[25]; int dp[100][100]; int main() { //FIN int n; while(~scanf("%d", &n)){ for(int i = 1; i <= n; i ++){ scanf("%d", &a[i]); dp[i][0] = 1; } dp[0][0] = 1; for(int i = 1; i <= n; i ++){ for(int j = 1; j <= 40; j ++){ dp[i][j] = dp[i - 1][j]; if(j >= a[i]){ dp[i][j] += dp[i - 1][j - a[i]]; } } } printf("%d\n", dp[n][40]); } }
OpenJudge Bailian 2755 神奇的口袋 DP
标签:
原文地址:http://www.cnblogs.com/Hyouka/p/5790950.html