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 huk at 2005-04-20 17:47:11 on Problem 1011
#include<iostream.h>
void main(){
	int len[100];
	int choice;
	while(1){
		cin>>choice;
		if(choice==0)
			break;
		for(int i=0;i<choice;i++)
			cin>>len[i];
		int sum=0;
		int max=len[0];
		for(i=0;i<choice;i++){
			sum+=len[i];
			if(max<len[i])
				max=len[i];
		}
		int *a;
		a=new int[choice];
		for(i=0;i<choice;i++)
			a[i]=0;
		int temp=sum;
		for(i=1;i<choice;i++){
			sum=temp;
			if(sum%i==0){
				sum/=i;
				if(sum<=max)
					break;
				a[i]=sum;
			}
		}
		int min=a[1];
		for(int j=1;j<i;j++){
			if(a[j]!=0 && a[j]<min)
				min=a[j];
		}
		cout<<min<<endl;
		delete []a;
	}
}

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