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

我怎么感觉我的这个程序这么短呀 难怪会WA

Posted by hpxyz70345 at 2007-07-24 00:18:15 on Problem 1011
In Reply To:高手帮忙看看阿~~~why TLE?????~~~~~~~~~~~~~ Posted by:never_gone at 2007-04-21 14:20:06
#include<iostream>
using namespace std;
#define N 64   
int main()
{
	int num,i,j;
	int a[N];
	int maxlen,alllen;
	for(int s=0;s<100;s++)
	{   maxlen=0;alllen=0;
		cout<<"input the number of sticks"<<endl;
	cin>>num;
	if(num>64||num<=0){cout<<"error!"<<endl;return 1;}
	else
	{
	for(i=0;i<num;i++)
	cin>>a[i];
	for(i=0;i<num;i++)
		if(a[i]>50||a[i]<0){cout<<"!wrrong"<<endl;return 1;}
	for(i=0;i<num;i++)
		if(a[i]>maxlen)maxlen=a[i];
	for(i=0;i<num;i++)
		alllen+=a[i];
	for(j=maxlen;j<=alllen;j++)
	if(alllen%j==0){cout<<j<<endl;break;}
		
	}
	}
	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