Thursday, 23 January 2014

UVa Problem ID 10812 (Beat the Spread)

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));
        StringBuffer sb=new StringBuffer("");
       
        int n=Integer.parseInt(br.readLine());
        for (int i = 0; i s || (s+d)%2!=0)
			{
				sb.append("impossible");
			}
			else if(d==s)
			{
				sb.append(s+" "+0);
			}
			else
			{
				int a=(s+d)/2;
				sb.append(a+" "+(s-a));
			}
			sb.append("\n");
		}
        System.out.print(sb);
    }
}

Previous Post
Next Post

0 comments:

Advertisement