(URI) Teste de Seleção 1 - Solução

import java.io.*;
import java.util.*;

class Main  {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   
        int a = leitor(br);
        int b = leitor(br);
        int c = leitor(br);
        int d = leitor(br);
       
        if (a%2 == 0 && c > 0 && d > 0 && b > c && d > a && (c+d) > (a+b)) {
            System.out.println("Valores aceitos");
        }
        else {
            System.out.println("Valores nao aceitos");
        }
    }
   
    static int leitor(BufferedReader br) throws NumberFormatException, IOException {      
        int n;
        int resp = 0;      

       
        while (true) {          
            n = br.read();          
            if (n >= '0' && n <= '9')
                break;
    
        } 
            
        while (true) {          
            resp = resp*10 + n-'0';          
            n = br.read();          
            if (n < '0' || n > '9')
                break;      
        }
       
        return resp;   
    }
}

Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução