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 |
Re:我承认是我的无知,现在A了,贴代码。In Reply To:Re:我承认是我的无知,现在A了,贴代码。 Posted by:gzw_02 at 2008-07-27 18:10:55 > # include <iostream> > > using namespace std; > > int const N=21; > int const WB=15001; > int const MID=7500; > int loc[N]; > int wgh[N]; > int state[N][WB]; > > int main(){ > int i,j,k,C,G,pw; > memset(state,0,sizeof(state)); > cin>>C>>G; > for(i=0;i<C;i++) > cin>>loc[i]; > for(i=0;i<G;i++){ > cin>>wgh[i]; > } > > for(i=0;i<C;i++){ > state[0][MID+wgh[0]*loc[i]]++; > } > for(i=1;i<G;i++){ > for(j=0;j<C;j++){ > for(k=0;k<=WB;k++){ > if((pw=k-wgh[i]*loc[j])<0) continue; > if(state[i-1][pw]){ > state[i][k]+=state[i-1][pw]; > } > } > } > } > cout<<state[G-1][MID]<<endl; > return 1; > } 求psc版本... Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator