(SPOJ) 18285 - Ano Novo - Solução 2

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

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 {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
       
        String line = "";
       
        int horas;
        int minutos;
        int segundos;
       
        while ((line = br.readLine()) != null) {
            String[] vetor = new String[3];
           
            vetor = line.split(":");
           
            horas = Integer.parseInt(vetor[0]);
            minutos = Integer.parseInt(vetor[1]);
            segundos = Integer.parseInt(vetor[2]);
           
            // 1m tem 60s
            // 1h tem 3600s
            // 24h tem 24x3600 = 86400s
            bw.write((86400 - horas*3600 - minutos*60 - segundos) + "\n");
           
        }
                       
        bw.flush();
        bw.close();           
        return;
    }
}

Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução