Last active
October 2, 2019 21:14
-
-
Save sofhiasouza/afd78935b4ea37dcf26c6b94952ca24f to your computer and use it in GitHub Desktop.
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
//Duas Notas - 2140 URI | |
//Solução por Sofhia Souza | |
#include <bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
int n, m, vet[6] = {2, 5, 10, 20, 50, 100}; //vet eh o vetor que guarda todas as 6 notas | |
while(cin >> n >> m, n, m) | |
{ | |
int troco = m-n, flag = 0; //troco eh o valor do troco que gil deve pagar e flag eh a variavel | |
//que vai me indicar se eh ou nao possivel | |
for(int i = 0 ; i < 6 ; i++) | |
{ | |
for(int j = i ; j < 6 ; j++) | |
{ | |
if(vet[i]+vet[j] == troco) flag = 1; //verifico para todos os pares possiveis | |
} //se a soma dos dois eh igual ao valor do troco, se sim | |
} //marco na flag que eh possivel | |
if(!flag) cout << "impossible\n"; | |
else cout << "possible\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment