(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");
       
        while ((line = br.readLine()) != null) {
            BigInteger entrada = new BigInteger(line);
            contador++;
            if (contador <= 2) {
                numero = numero.multiply(entrada);
                if (contador == 2) {
                    System.out.println(numero);
                    numero = new BigInteger("1");
                    contador = 0;
                } 
            }
        }
       
        return;
    }
}

Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução