-
-
Save murilomaeda/8c5535e78556ec9ebe12b2c1da1943ad 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
#include<bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
cin.tie(0)->sync_with_stdio(0); | |
//vector com os 6 números de entrada | |
vector<int> v; | |
for(int i = 0; i < 6; i++) | |
{ | |
int aux; cin >> aux; | |
v.push_back(aux); | |
} | |
//ordeno para o next_permutation checar todos os casos | |
sort(v.begin(),v.end()); | |
//guarda se consegui achar uma posição que é válida | |
bool dah = false; | |
//enquanto tiver uma permutação que não foi testada, testo ela e tento gerar outra | |
do | |
{ | |
int primeira = v[5]; | |
int segunda = v[3] + v[4]; | |
int terceira = v[0] + v[1] + v[2]; | |
//testo se satisfaz a condição | |
if(primeira == segunda && segunda == terceira) dah = true; | |
} | |
while(next_permutation(v.begin(),v.end())); | |
//a função next_permutation gera, para uma sequência, a próxima em ordem lexicográfica | |
//se tiver uma próxima, ela retorna true, se não, retorna false | |
if(dah) cout << "S"; | |
else cout << "N"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment