天天看点

POJ1247解题报告

import java.util.Scanner;

public class Main {
	/**
	 * @param args
	 */
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		int[] b;
		do{
			int num=input.nextInt();
			if(num==0)break;
			b=new int[num];
			int sum=0,ellen=0,mid=0;
			for(int i=0;i<num;i++){
				b[i]=input.nextInt();
				sum+=b[i];
			}
			mid=sum/2;
			if(sum%2!=0)System.out.println("No equal partitioning.");
			else{
				for(int i=0;i<num;i++){
					ellen+=b[i];
					if(ellen==mid){
						System.out.println("Sam stops at position "+(i+1)+" and Ella stops at position "+(i+2)+".");
						break;
					}
					else if(ellen>mid){
						System.out.println("No equal partitioning.");
						break;
					}
					else ;
				}
			}
			
		}while(true);
		input.close();
	}
}