Thursday, 23 January 2014

UVa Problem ID 11498 (Division of Nlogonia)

UVa Problem ID 11498 (Division of Nlogonia)
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("");
        while(true)
        {
	        int K=Integer.parseInt(br.readLine());
	        if(K<=0 || K>1000)
	        	break;
	        String s[]=br.readLine().split(" ");
	        int N=Integer.parseInt(s[0]);
	        int M=Integer.parseInt(s[1]);
	        if(N<-10000 || N>10000 || M<-10000 || M>10000)
	        	break;
	        for (int i = 0; i 10000 || Y<-10000 || Y>10000)
	            	break;
	            //System.out.println("K="+K+" N="+N+" M="+M+" X="+X+" Y="+Y);
	            if(X==N || Y==M)
	            {
	            	sb.append("divisa");
	            }
	            else if(XM)
	            {
	            	sb.append("NO");
	            }
	            else if(XN && Y>M)
	            {
	            	sb.append("NE");
	            }
	            else if(X>N && Y

UVa Problem ID 11547 (Automatic Answer)

UVa Problem ID 11547 (Automatic Answer)
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;
        StringBuffer sb=new StringBuffer("");
       
        int t=Integer.parseInt(br.readLine());
        if(t<1 || t>100)
        	System.exit(0);
        for (int i = 0; i 1000)
            	break;
        	String s=""+(315*n+36962);
        	if(s.length()>=2)
        		sb.append(s.charAt(s.length()-2));
        	else
        		sb.append(0);
        	sb.append("\n");
        }
        System.out.print(sb);
    }
}

UVa Problem ID 11044 (Searching For Nessy)

UVa Problem ID 11044 (Searching For Nessy)
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 t=Integer.parseInt(br.readLine());
        for (int i = 0; i 10000 || m<6 ||m>10000)
				break;
			int ans=(int)(Math.ceil((n-2)/3.0)*Math.ceil((m-2)/3.0));
			sb.append(ans);
			sb.append("\n");
		}
        System.out.print(sb);
    }
}

UVa Problem ID 10921 (Find the Telephone)

UVa Problem ID 10921 (Find the Telephone)
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;
        StringBuffer sb=new StringBuffer("");
       
        while((input=br.readLine())!=null)
        {
		if(input.length()<1 ||input.length()>30)
        		break;
        	for (int i = 0; i < input.length(); i++) 
        	{
				switch (input.charAt(i)) 
				{
					case '1':
					case '-':
					case '0':
					{
						sb.append(input.charAt(i));
						break;
					}
					case 'A':
					case 'B':
					case 'C':
					{
						sb.append(2);
						break;
					}
					case 'D':
					case 'E':
					case 'F':
					{
						sb.append(3);
						break;
					}
					case 'G':
					case 'H':
					case 'I':
					{
						sb.append(4);
						break;
					}
					case 'J':
					case 'K':
					case 'L':
					{
						sb.append(5);
						break;
					}
					case 'M':
					case 'N':
					case 'O':
					{
						sb.append(6);
						break;
					}
					case 'P':
					case 'Q':
					case 'R':
					case 'S':
					{
						sb.append(7);
						break;
					}
					case 'T':
					case 'U':
					case 'V':
					{
						sb.append(8);
						break;
					}
					case 'W':
					case 'X':
					case 'Y':
					case 'Z':
					{
						sb.append(9);
						break;
					}
				}
			}
        	sb.append("\n");
        }
        System.out.print(sb);
    }
}

UVa Problem ID 10812 (Beat the Spread)

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);
    }
}

Advertisement