import java.util.Calendar ;
import java.util.GregorianCalendar ;
class Teste {
private static void mostrar
( Horario agora,
String objetivo
) { Horario desejada = Horario.parse ( objetivo) ;
Horario falta = desejada.diferenca ( agora) ;
"Entre " + agora
+ " e " + desejada
+ ", a diferença é de " + falta
+ "." ) ;
}
public static void main
( String [ ] args
) { Horario agora = Horario.agora ( ) ;
mostrar( agora, "07:30" ) ;
mostrar( new Horario( 5 , 30 ) , "07:30" ) ;
mostrar( new Horario( 7 , 10 ) , "07:30" ) ;
mostrar( new Horario( 0 , 0 ) , "07:30" ) ;
mostrar( new Horario( 7 , 0 ) , "07:30" ) ;
mostrar( new Horario( 7 , 30 ) , "07:30" ) ;
mostrar( new Horario( 7 , 31 ) , "07:30" ) ;
mostrar( new Horario( 10 , 0 ) , "07:30" ) ;
mostrar( new Horario( 19 , 30 ) , "07:30" ) ;
mostrar( new Horario( 23 , 59 ) , "07:30" ) ;
mostrar( new Horario( 0 , 0 ) , "23:59" ) ;
mostrar( new Horario( 23 , 59 ) , "00:00" ) ;
}
}
class Horario {
private final int horas;
private final int minutos;
public Horario( int horas, int minutos) {
if ( horas < 0 || horas > 23 || minutos < 0 || minutos > 59 ) {
}
this .horas = horas;
this .minutos = minutos;
}
public int getHoras( ) {
return horas;
}
public int getMinutos( ) {
return minutos;
}
public static Horario parse
( String input
) { char [ ] cs = input.toCharArray ( ) ;
for ( int i = 0 ; i < 5 ; i++ ) {
if ( i == 2 ) continue ;
}
int h = ( cs[ 0 ] - '0' ) * 10 + cs[ 1 ] - '0' ;
int m = ( cs[ 3 ] - '0' ) * 10 + cs[ 4 ] - '0' ;
return new Horario( h, m) ;
}
public static Horario agora( ) {
}
public Horario diferenca( Horario outro) {
int difHoras = this .horas - outro.horas ;
int difMinutos = this .minutos - outro.minutos ;
while ( difMinutos < 0 ) {
difMinutos += 60 ;
difHoras--;
}
while ( difHoras < 0 ) {
difHoras += 24 ;
}
return new Horario( difHoras, difMinutos) ;
}
@Override
return ( ( horas < 10 ) ? "0" : "" ) + horas + ":" + ( ( minutos < 10 ) ? "0" : "" ) + minutos;
}
}
aW1wb3J0IGphdmEudXRpbC5DYWxlbmRhcjsKaW1wb3J0IGphdmEudXRpbC5HcmVnb3JpYW5DYWxlbmRhcjsKCmNsYXNzIFRlc3RlIHsKCiAgICBwcml2YXRlIHN0YXRpYyB2b2lkIG1vc3RyYXIoSG9yYXJpbyBhZ29yYSwgU3RyaW5nIG9iamV0aXZvKSB7CiAgICAgICAgSG9yYXJpbyBkZXNlamFkYSA9IEhvcmFyaW8ucGFyc2Uob2JqZXRpdm8pOwogICAgICAgIEhvcmFyaW8gZmFsdGEgPSBkZXNlamFkYS5kaWZlcmVuY2EoYWdvcmEpOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigKICAgICAgICAJICAgICJFbnRyZSAiICsgYWdvcmEKICAgICAgICAgICAgICAgICsgIiBlICIgKyBkZXNlamFkYQogICAgICAgICAgICAgICAgKyAiLCBhIGRpZmVyZW7Dp2Egw6kgZGUgIiArIGZhbHRhCiAgICAgICAgICAgICAgICArICIuIik7CiAgICB9CgogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIEhvcmFyaW8gYWdvcmEgPSBIb3JhcmlvLmFnb3JhKCk7CiAgICAgICAgbW9zdHJhcihhZ29yYSwgIjA3OjMwIik7CiAgICAgICAgbW9zdHJhcihuZXcgSG9yYXJpbyggNSwgMzApLCAiMDc6MzAiKTsKICAgICAgICBtb3N0cmFyKG5ldyBIb3JhcmlvKCA3LCAxMCksICIwNzozMCIpOwogICAgICAgIG1vc3RyYXIobmV3IEhvcmFyaW8oIDAsICAwKSwgIjA3OjMwIik7CiAgICAgICAgbW9zdHJhcihuZXcgSG9yYXJpbyggNywgIDApLCAiMDc6MzAiKTsKICAgICAgICBtb3N0cmFyKG5ldyBIb3JhcmlvKCA3LCAzMCksICIwNzozMCIpOwogICAgICAgIG1vc3RyYXIobmV3IEhvcmFyaW8oID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eGNlcHRpb24oKTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IDU7IGkrKykgewogICAgICAgIAlpZiAoaSA9PSAyKSBjb250aW51ZTsKICAgICAgICAgICAgaWYgKGNzW2ldIDwgJzAnIHx8IGNzW2ldID4gJzknKSB0aHJvdyBuZXcgSWxsZWdhbEFyZ3VtZW50RXhjZXB0aW9uKCk7CiAgICAgICAgfQogICAgICAgIGlmIChjc1syXSAhPSAnOicpIHRocm93IG5ldyBJbGxlZ2FsQXJndW1lbnRFeGNlcHRpb24oKTsKCiAgICAgICAgaW50IGggPSAoY3NbMF0gLSAnMCcpICogMTAgKyBjc1sxXSAtICcwJzsKICAgICAgICBpbnQgbSA9IChjc1szXSAtICcwJykgKiAxMCArIGNzWzRdIC0gJzAnOwogICAgICAgIHJldHVybiBuZXcgSG9yYXJpbyhoLCBtKTsKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIEhvcmFyaW8gYWdvcmEoKSB7CiAgICAgICAgR3JlZ29yaWFuQ2FsZW5kYXIgZ2MgPSBuZXcgR3JlZ29yaWFuQ2FsZW5kYXIoKTsKICAgICAgICByZXR1cm4gbmV3IEhvcmFyaW8oZ2MuZ2V0KENhbGVuZGFyLkhPVVJfT0ZfREFZKSwgZ2MuZ2V0KENhbGVuZGFyLk1JTlVURSkpOwogICAgfQoKICAgIHB1YmxpYyBIb3JhcmlvIGRpZmVyZW5jYShIb3JhcmlvIG91dHJvKSB7CiAgICAgICAgaW50IGRpZkhvcmFzID0gdGhpcy5ob3JhcyAtIG91dHJvLmhvcmFzOwogICAgICAgIGludCBkaWZNaW51dG9zID0gdGhpcy5taW51dG9zIC0gb3V0cm8ubWludXRvczsKICAgICAgICB3aGlsZSAoZGlmTWludXRvcyA8IDApIHsKICAgICAgICAgICAgZGlmTWludXRvcyArPSA2MDsKICAgICAgICAgICAgZGlmSG9yYXMtLTsKICAgICAgICB9CiAgICAgICAgd2hpbGUgKGRpZkhvcmFzIDwgMCkgewogICAgICAgICAgICBkaWZIb3JhcyArPSAyNDsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIG5ldyBIb3JhcmlvKGRpZkhvcmFzLCBkaWZNaW51dG9zKTsKICAgIH0KCiAgICBAT3ZlcnJpZGUKICAgIHB1YmxpYyBTdHJpbmcgdG9TdHJpbmcoKSB7CiAgICAgICAgcmV0dXJuICgoaG9yYXMgPCAxMCkgPyAiMCIgOiAiIikgKyBob3JhcyArICI6IiArICgobWludXRvcyA8IDEwKSA/ICIwIiA6ICIiKSArIG1pbnV0b3M7CiAgICB9Cn0=
stdout
Entre 05:53 e 07:30, a diferença é de 01:37.
Entre 05:30 e 07:30, a diferença é de 02:00.
Entre 07:10 e 07:30, a diferença é de 00:20.
Entre 00:00 e 07:30, a diferença é de 07:30.
Entre 07:00 e 07:30, a diferença é de 00:30.
Entre 07:30 e 07:30, a diferença é de 00:00.
Entre 07:31 e 07:30, a diferença é de 23:59.
Entre 10:00 e 07:30, a diferença é de 21:30.
Entre 19:30 e 07:30, a diferença é de 12:00.
Entre 23:59 e 07:30, a diferença é de 07:31.
Entre 00:00 e 23:59, a diferença é de 23:59.
Entre 23:59 e 00:00, a diferença é de 00:01.