Created
July 22, 2019 13:09
-
-
Save marty1885/a5750db6810e2b95dbb97685bc6bcd88 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
int main() | |
{ | |
size_t n = 0; | |
size_t count = 0; | |
while(std::cin >> n) { | |
std::vector<size_t> vec(n); | |
for(auto & v : vec) cin >> v; | |
std::sort(vec.begin(), vec.end()); | |
std::set<size_t> s; | |
bool good = true; | |
for(size_t i=0;i<n;i++) { | |
size_t a = vec[i]; | |
for(size_t j=i;j<n;j++) { | |
size_t b = vec[j]; | |
//std::cout << i << " " << j << " " << a+b << std::endl; | |
if(s.find(a+b) != s.end()) { | |
good = false; | |
break; | |
} | |
s.insert(a+b); | |
} | |
if(good == false) break; | |
} | |
if(good) | |
std::cout << "Case #" << count <<": It is a B2-Sequence.\n\n"; | |
else | |
std::cout << "Case #" << count << ": It is not a B2-Sequence.\n\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment