Created
June 8, 2016 11:52
-
-
Save rogerioagjr/a6293b700e292f7611f1642e5c14de79 to your computer and use it in GitHub Desktop.
Lâmpadas do hotel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lâmpadas do hotel - F1P2 - OBI 2016 | |
// Rogério Júnior | |
// Complexidade: O(1) | |
#include <cstdio> | |
int ia, ib, fa, fb, resp; | |
int main(){ | |
scanf("%d %d %d %d", &ia, &ib, &fa, &fb); | |
// se os estados inicial e final de B forem diferentes | |
if(fb!=ib){ | |
// aperto o interruptor 2 | |
// então aumento 1 em resp | |
resp++; | |
// e troco o estado da lâmpada A | |
ia=(!ia); | |
} | |
// se os estados inicial e final de A forem diferentes | |
if(ia!=fa) resp++; // aumento 1 em resp | |
// por fim, imprimo o valor de resp | |
printf("%d\n", resp); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment