Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
第一道DP,贴代码,飘过~#include <iostream> #define MAX 7500 #define For(i,a,b) for(int i = a;i <= b;i++) using namespace std; int dp[22][15002]; int cc[22]; int cg[22]; int main() { int c,g; while(scanf("%d%d",&c,&g) != EOF) { memset(dp,0,sizeof(dp)); dp[0][7500] = 1; For(i,1,c) scanf("%d",&cc[i]); For(i,1,g) scanf("%d",&cg[i]); For(i,1,g) For(j,1,15000) if(dp[i-1][j]) For(k,1,c) dp[i][j + cg[i] * cc[k]] += dp[i - 1][j]; cout << dp[g][7500] << endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator