Monday, 24 February 2014

UVA Problem ID 12279 (Emoogle Balance)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main (String args[]) throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String input;
		StringBuilder sb=new StringBuilder(1000);
		int testcase=0;
		while((input=br.readLine())!=null)
		{
			if(Integer.parseInt(input.trim())==0)
				break;
			testcase++;
			String s[]=br.readLine().split(" +");
			int reason=0;
			int party=0;
			for (int i = 0; i < Integer.parseInt(input.trim()); i++) {
				if(Integer.parseInt(s[i])>0)
					reason++;
				else 
					party++;
			}
			sb.append("Case "+testcase+": "+(reason-party)+"\n");
		}
		System.out.print(sb);
	}
}

Previous Post
Next Post

0 comments:

Advertisement