Skip to content

Instantly share code, notes, and snippets.

@marty1885
Created July 22, 2019 13:09
Show Gist options
  • Save marty1885/a5750db6810e2b95dbb97685bc6bcd88 to your computer and use it in GitHub Desktop.
Save marty1885/a5750db6810e2b95dbb97685bc6bcd88 to your computer and use it in GitHub Desktop.
#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