Posts

Showing posts from December, 2013

(SPOJ) 3828 - Primo - Solução

import java.io.*; import java.util.*; import java.lang.Math; import java.math.*; class Main {     public static void main(String[] args) throws NumberFormatException, IOException {         Main processando = new Main();         processando.processa();                 System.exit(0);     }         void processa() throws NumberFormatException, IOException {         String line = "";                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));         line = br.readLine();         StringTokenizer tokenizer = new StringTokenizer(line);         int numero = Int...

(SPOJ) 840 - Cofrinhos da Vó Vitória - Solução

import java.io.*; import java.util.*; import java.lang.Math; import java.math.*; class Main {     public static void main(String[] args) throws NumberFormatException, IOException {         Main processando = new Main();         processando.processa();                 System.exit(0);     }         void processa() throws NumberFormatException, IOException {         String line = "";                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));         int contador = 0;                while((line = br.readLine()) != null) {       ...

(SPOJ) 8697 - Pneu - Solução

import java.io.*; import java.util.*; import java.lang.Math; import java.math.*; class Main {     public static void main(String[] args) throws NumberFormatException, IOException {         Main processando = new Main();         processando.processa();                 System.exit(0);     }         void processa() throws NumberFormatException, IOException {         String line = "";                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));                 line = br.readLine();         StringTokenizer tokenizer = new StringTokenizer(line);   ...

(SPOJ) 3774 - Fatorial - Solução

import java.io.*; import java.util.*; import java.lang.Math; import java.math.*; class Main {     public static void main(String[] args) throws NumberFormatException, IOException {         Main processando = new Main();         processando.processa();                 System.exit(0);     }         void processa() throws NumberFormatException, IOException {         String line = "";                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));                 line = br.readLine();         StringTokenizer tokenizer = new StringTokenizer(line);   ...

(SPOJ) 3829 - Quadrados - Solução

import java.io.*; import java.util.*; import java.lang.Math; import java.math.*; class Main {     public static void main(String[] args) throws NumberFormatException, IOException {         Main processando = new Main();         processando.processa();                 System.exit(0);     }         void processa() throws NumberFormatException, IOException {         String line = "";                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));                 line = br.readLine();         StringTokenizer tokenizer = new StringTokenizer(line);   ...

(SPOJ) 1387 - Transmissão de Energia - Solução

import java.io.*; import java.util.*; class Main {     public static void main(String[] args) throws NumberFormatException, IOException {         Main processando = new Main();         processando.takeInput();                 System.exit(0);     }         void buscaProf(int[][] matriz, ArrayList<Integer> visitados, int qteEstacoes, int ponto) {         visitados.set(ponto, 1);         for (int i = 0; i < qteEstacoes; i++) {             if (matriz[ponto][i] == 1) {                 if (visitados.get(i) == 0) {              ...

(UVA) 10116 - Robot Motion - Solução

import java.io.*; import java.util.*; class Main {     public static void main(String[] args) throws NumberFormatException, IOException {         Main processando = new Main();         processando.takeInput();                System.exit(0);     }     char[][] leMapa(BufferedReader br, int linha, int coluna) throws NumberFormatException, IOException  {         char[][] matrizChar = new char[linha][coluna];         String conteudoLinha;                for (int i = 0; i < linha; i++) {             conteudoLinha = br.readLine();             for (int j = 0; j ...

(UVA) 11332 - Summing Digits - 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 resultado = "";                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));                         while ((resultado = br.readLine()) != null) {       ...

(UVA) 10137 - The Trip - Solução

import java.io.*; import java.util.*; import java.lang.Math; import java.text.NumberFormat; import java.text.DecimalFormat;   import java.text.DecimalFormatSymbols; import java.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 = "";                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));                ...

(UVA) 10082 - WERTYU - 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 = "";         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));                 Map<Character, Character> teclado = new TreeMap<Character, Character>();                 teclado...

(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(n...

(UVA) 10035 - Primary Arithmetic - 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 = "";                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));                 line = br.readLine();         Integer tamanho = line.length();       ...

(UVA) 10106 - Product - Solução

import java.io.*; import java.util.*; import java.lang.Math; import java.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 = "";                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));           Integer contador = 0;         BigInteger numero = new BigInteger("1");         ...

(UVA) 10071 - Back to High School Physics - 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 entrada = "";                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));                 while ((entrada = br.readLine()) != null) {               ...

(UVA) 10018 - Reverse and Add - 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 = "";         String entrada = "";         StringTokenizer tokenizer = null;                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));               ...

(UVA) 344 - Roman Digititis - Solução

import java.io.*; import java.util.*; class Main {     public static void main(String[] args) throws NumberFormatException, IOException {         Main processando = new Main();         processando.takeInput();                 System.exit(0);     }     List<Integer> geraQuantidade(int numeroEntrada) {         List<Integer> lista = new ArrayList<Integer>();             int n = 1;         int i = 0;         int v = 0;         int x = 0;         int l = 0;         int c = 0;       ...

(UVA) 10107 - What is the Median? - 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;                 int[] vetor = new int[10000];         int contador = 0;                 BufferedReader br = new BufferedReader(n...

(UVA) 12626 - I ❤ Pizza - Solução

import java.io.*; import java.util.*; 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;                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));                 line = br.readLine();         tokenizer = new S...