(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) {
            StringTokenizer tokenizer = new StringTokenizer(line);
            int qte = Integer.valueOf(tokenizer.nextToken());

            if (qte == 0) {
                return;
            }
           
            contador++;
            System.out.println("Teste " + contador);
           
            int soma1 = 0;
            int soma2 = 0;
            for (int i = 0; i < qte; i++) {
                line = br.readLine();
                tokenizer = new StringTokenizer(line);
               
                soma1 += Integer.valueOf(tokenizer.nextToken());
                soma2 += Integer.valueOf(tokenizer.nextToken());
                           
                System.out.println(soma1-soma2);           
            }
                       
            System.out.println();
        }
                   
        return;
    }
}

Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução