(UVA) 11479 - Is this the easiest problem? - Solução

import java.io.*;
import java.util.*;
import java.lang.Math;

class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        Main processando = new Main();
        processando.takeInput();
       
        System.exit(0);
    }
   
    void takeInput() throws NumberFormatException, IOException {
        String line = "";
        StringTokenizer tokenizer = null;
       
        String entrada = "";
        long[] vetor = new long[3];
       
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      
        line = br.readLine();
        tokenizer = new StringTokenizer(line);
        int n = Integer.parseInt(tokenizer.nextToken());
        int contador = 0;
       
        while (contador < n) {       
            entrada = br.readLine();
            String[] str = entrada.split(" ");
            int i = 0;
            while (i < 3) {
                vetor[i] = Integer.parseInt(str[i]);
                i++;
            }

            long a = vetor[0];
            long b = vetor[1];
            long c = vetor[2];
           
            contador++;     
            if (a >= (b+c) || b >= (a+c) || c >= (a+b) || a < 1 || b < 1 || c < 1) {
                System.out.println("Case " + contador + ": Invalid");
            }
            else if (a == b && b == c) {
                System.out.println("Case " + contador + ": Equilateral");
            }
            else if (a == b || a == c || b == c) {
                System.out.println("Case " + contador + ": Isosceles");
            }
            else {
                System.out.println("Case " + contador + ": Scalene");
            }
        }
       
       
        return;
    }
}

Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução