Skip to content

Instantly share code, notes, and snippets.

@tuxes
Created February 6, 2011 13:07
Show Gist options
  • Save tuxes/813355 to your computer and use it in GitHub Desktop.
Save tuxes/813355 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
int main() {
int h, m, s, cs;
while (scanf("%02d%02d%02d%02d", &h, &m, &s, &cs) != EOF) {
unsigned long long time = h*60*60*100 + m*60*100 + s*100 + cs;
printf("%07llu\n", time*10000000/8640000);
}
return 0;
}
/*
http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1624
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
int main() {
int i, h, m, s, cs;
char testes[5][9] = { "00000000", "23595999", "12000000", "14273467", "02475901" };
char respostas[5][9] = { "0000000", "9999998", "5000000", "6024846", "1166552" };
char solucao[9];
for (i = 0; i < 5; i++) {
sscanf(testes[i], "%02d%02d%02d%02d", &h, &m, &s, &cs);
unsigned long long time = h*60*60*100 + m*60*100 + s*100 + cs;
sprintf(solucao, "%07llu\n", time*10000000/8640000);
printf("Teste %d...\t", i);
assert ( strcmp(solucao, respostas[i]) );
printf("OK\n");
}
puts("Todos os testes passaram");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment