Last active
September 7, 2021 21:00
-
-
Save luciocf/7c2e41d99be3afd57639b6fae9518698 to your computer and use it in GitHub Desktop.
Comentário NOIC - OBI Fase 2 PJ - Pesquisa de preços
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
// Comentário NOIC - OBI Fase 2 PJ - Pesquisa de preços | |
// Complexidade: O(n) | |
// Escrito por Lúcio Figueiredo | |
#include <bits/stdc++.h> | |
using namespace std; | |
int main(void) | |
{ | |
int n; | |
scanf("%d", &n); | |
bool vantajoso = 0; // indica se é vantajoso usar álcool em algum estado | |
for (int i = 1; i <= n; i++) | |
{ | |
char c1, c2; // estado | |
double a, g; // preço de álcool, gasolina | |
scanf(" %c %c %lf %lf", &c1, &c2, &a, &g); | |
if (a*100.0 <= 70.0*g) // a <= 70% * g | |
{ | |
vantajoso = 1; | |
printf("%c%c\n", c1, c2); | |
} | |
} | |
if (!vantajoso) printf("*\n"); // em nenhum estado é vantajoso usar álcool | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment