Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

第一道DP,贴代码,飘过~

Posted by yingxiang720 at 2011-03-25 23:23:32 on Problem 1837
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator