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

Re:改成这样可AC

Posted by zhongwei1025 at 2011-05-22 21:25:26 on Problem 1247
In 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:
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