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 |
Re:改成这样可ACIn Reply To:改成这样可AC Posted by:ecjtuzdh at 2008-12-26 15:11:34 > #include <stdio.h> > > int main() > { > int n,a[35],i; > int b,c,j,k; > while(scanf("%d",&n)!=EOF && n) > { > b=0,c=0,j=1,k=n; > for(i=1;i<=n;i++) > scanf("%d",&a[i]); > while(1) > { > if(c<=b) > { > c+=a[j]; > j++; > } > else > { > b+=a[k]; > k--; > } > if(c==b && j-1==k) > { > printf("Sam stops at position %d and Ella stops at position %d.\n",j-1,k+1); > break; > } > if(j-1>k) > { > printf("No equal partitioning.\n"); > break; > } > } > } > return 0; > } > /* > #include<iostream.h> > > int main() > { > int N; > int a[31]={0}; > int S=0;//clockwise > int E=0;//counterclockwise > int position1, position2; > > while(1) > { > cin>>N; > > if(N==0) > return 0; > > for(int i=1;i<=30;i++) > a[i]=0; > > for(i=1;i<=N;i++) > cin>>a[i]; > > position1=1; > position2=N; > > > while(1) > { > if(S<=E) > { > S=a[position1]+S; > position1++; > } > else > { > E=a[position2]+E; > position2--; > } > if(S==E&&(position1-1)==position2) > { > cout<<"Sam stops at position "<<position1-1<<" and Ella stops at position "<<position2+1<<"."<<endl; > break; > } > if((position1-1)>position2) > { > cout<<"No equal partitioning."<<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