Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n, b;
- while(cin >> n >> b && n != 0 && b != 0) {
- vector<int> balls(b);
- vector<bool> numbers(n + 1, false);
- for(int i = 0; i < b; ++i) cin >> balls[i];
- for(int i = 0; i < b; ++i) {
- for(int j = i; j < b; ++j) {
- int currNum = abs(balls[i] - balls[j]);
- numbers[currNum] = true;
- }
- }
- bool ans = true;
- for(int i = 0; i <= n && ans; ++i) {
- ans &= numbers[i];
- }
- if(ans) cout << "Y" << endl;
- else cout << "N" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement