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 |
我怎么感觉我的这个程序这么短呀 难怪会WAIn 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator