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

哪里错了,我自己看不出啊!!

Posted by lian at 2005-04-29 18:04:08 on Problem 1014
#include<iostream.h>
//#include<mem.h>

int main(){
	long int a[7]={0,0,0,0,0,0,0}, m[7]={0,0,0,0,0,0,0}, sum=0, Msum=0,time=1;

	for(int i=1; i<7; i++){
		cin>>a[i];
		sum+=a[i]*i;;
	}
	while(sum!=0){
		cout<<"Collection #"<<time<<':'<<endl;
		for(int i=1; i<7; i++){
			if(a[i]%2==0)
				m[i]=a[i]/2;
			else
				m[i]=(a[i]+1)/2;
		}
		for(i=1; i<7; i++)
			Msum+=m[i]*i;
		
		if(sum%2==1)
			cout<<"Can't be divided.\n"<<endl;
		else{
			if((Msum-sum/2)%2!=0)
				cout<<"Can't be divided.\n"<<endl;
			else{
				int p=Msum-sum/2;
                for(int i=6; i>0; i--){
					int n=p/i;
				    n=(n<=m[i]? n:a[i]);
				    p=p-n*i;
				} 
		    	if(p==0)
			    	cout<<"Can be divided.\n"<<endl;
	    		else 
		    		cout<<"Can't be divided.\n"<<endl;
			}
		}
		Msum=0;
        sum=0;
		for(i=1; i<7; i++){
			a[i]=0;
			m[i]=0;
		}
		for(i=1; i<7; i++){
			cin>>a[i];
		    sum+=a[i]*i;
		}
        time++;
	}
	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