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

please tell me which place is wrong

Posted by pkueducn1 at 2005-01-10 15:36:02 on Problem 1014
#include<stdio.h>
void main(){
	long a[7],i,sum,p,k,sum1,j;
	for(k=1;;k++){
		sum=0;
	    for(i=1;i<=6;i++){
		    scanf("%d",&a[i]);
	    	sum+=i*a[i];
		}
		if(sum==0) break;
		p=sum/2;
		sum1=0;
		if(sum!=p*2)
			printf("Collection #%d:\nCan't be divided.\n",k);
		else {
			for(i=1;i<6;i++){
			  for(j=1;j<=a[i];j++){
				sum1+=i;
				if(sum1>=p)break;
			  }
			  if(sum1>=p)break;
			}
			if(sum1==p)printf("Collection #%d:\nCan be divided.\n",k);
			else printf("Collection #%d:\nCan't be divided.\n",k);
		}
		printf("\n");
	}
}

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