Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n, b;
  7.     while(cin >> n >> b && n != 0 && b != 0) {
  8.         vector<int> balls(b);
  9.         vector<bool> numbers(n + 1, false);
  10.         for(int i = 0; i < b; ++i) cin >> balls[i];
  11.         for(int i = 0; i < b; ++i) {
  12.             for(int j = i; j < b; ++j) {
  13.                 int currNum = abs(balls[i] - balls[j]);
  14.                 numbers[currNum] = true;
  15.             }
  16.         }
  17.         bool ans = true;
  18.         for(int i = 0; i <= n && ans; ++i) {
  19.             ans &= numbers[i];
  20.         }
  21.         if(ans) cout << "Y" << endl;
  22.         else cout << "N" << endl;
  23.     }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement