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:哪个程序可以过这个这个数据: 12 0 0 0 0 1In Reply To:哪个程序可以过这个这个数据: 12 0 0 0 0 1 Posted by:qiqilrq at 2007-08-14 19:30:12 #include<iostream> using namespace std; int m1[60001],m2[120001]; int array[7]; int calc(int *s,int m,int n) { int i,j,k,sum=0,rest; for(i=1;i<60001;i++) s[i]=0; s[0]=1; for(i=m;i<=n;i++) { sum+=array[i]*i; for(j=1;j<array[i];j*=2) { for(k=sum;k>=j*i;k--) if(s[k]==0&&s[k-j*i]) s[k]=1; } j=array[i]-j/2; for(k=sum;k>=j*i;k--) if(s[k]==0&&s[k-j*i]) s[k]=1; } } int main() { int i,times=1,a,flag; while(cin>>array[1]) { flag=0; array[0]=0; for(i=2;i<7;i++) { cin>>array[i]; array[0]+=array[i]*i; } array[0]+=array[1]; if(array[0]==0) break; if(array[0]&0x1) {cout<<"Collection #"<<times++<<":"<<endl;cout<<"Can't be divided.\n"<<endl;continue;} array[0]/=2; calc(m1,1,3); calc(m2,4,6); for(i=0;i<array[0];i++) if(m1[i]&&m2[array[0]-i]) { flag=1;break; } cout<<"Collection #"<<times++<<":"<<endl; if(flag) cout<<"Can be divided."<<endl; else cout<<"Can't be divided."<<endl; cout<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator