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:搞错了In Reply To:Re:关于此题可以证明如下结论。。。。。 Posted by:zhucheng at 2004-12-08 23:11:11 > my code > > #include <iostream> > using namespace std; > int marble[6]; > const int limit[]={3,4,5,4,6,5}; > > > bool half(int d,int next) > { > if(d==0) > return true; > if(next==0) > return false; > int i; > for(i=marble[next-1];i>=0;i--) > { > if(d>=i*next) > { > marble[next-1]-=i; > if(half(d-i*next,next-1)) > return true; > marble[next-1]+=i; > } > } > return false; > } > > int main() > { > int i,test=1,sum=0; > for(i=0;i<6;i++) > { > cin>>marble[i]; > if(marble[i]>limit[i]) > { > marble[i]=limit[i]-(marble[i]-limit[i])%2; > } > sum+=marble[i]*(i+1); > } > while(sum!=0) > { > if(sum%2==0&&half(sum/2,6)) > { > cout<<"Collection #"<<test++<<":"<<endl; > cout<<"Can be divided.\n"<<endl; > } > else > { > cout<<"Collection #"<<test++<<":"<<endl; > cout<<"Can't be divided.\n"<<endl; > } > sum=0; > for(i=0;i<6;i++) > { > cin>>marble[i]; > if(marble[i]>limit[i]) > { > marble[i]=limit[i]-(marble[i]-limit[i])%2; > } > sum+=marble[i]*(i+1); > } > } > return 0; > } > > > > > > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator