Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <cmath>
- #include <algorithm>
- #include <memory.h>
- #include <stdio.h>
- #include <stack>
- #include <deque>
- #include <queue>
- #include <vector>
- #include <set>
- #include <iterator>
- #include <map>
- #include <iomanip>
- #include <unordered_set>
- #define int long long
- #define sp system("pause")
- #define pb push_back
- #define double long double
- #define endl "\n"
- #define un unsigned
- #define INF 1000000009
- #define pii pair<int, int>
- #define un unsigned
- #define all(v) v.begin(), v.end()
- using namespace std;
- int n1;
- istream& operator >> (istream& in, vector<int>& a)
- {
- for (int i = 0; i < n1; i++)
- {
- in >> a[i];
- }
- return in;
- }
- ostream& operator << (ostream& out, vector<char>& a)
- {
- for (int i = n1 - 1; i > -1; i--)
- {
- out << a[i];
- }
- return out;
- }
- int gcd(un int a, un int b)
- {
- if (a == 0 || b == 0)
- {
- return a + b;
- }
- return gcd(b % a, a);
- }
- void exteded_gcd(int a, int b, int& x, int& y)
- {
- if (a == 0)
- {
- x = 0;
- y = 1;
- return;
- }
- int x1, y1;
- exteded_gcd(b % a, a, x1, y1);
- x = y1 - (b / a) * x1;
- y = x1;
- return;
- }
- bool isPrime(int a)
- {
- int d = 2;
- if (a == 1)
- {
- return false;
- }
- while (d * d <= a)
- {
- if (a % d == 0)
- {
- return false;
- }
- d++;
- }
- return true;
- }
- signed main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int n, v;
- cin >> n >> v;
- vector <int> vc(n);
- for (int i = 0; i < n; i++)
- {
- cin >> vc[i];
- }
- if (n == 1)
- {
- if (vc[0] != v)
- {
- cout << "NO";
- }
- else
- {
- cout << "YES";
- }
- return 0;
- }
- int d = gcd(vc[0], vc[1]);
- for (int i = 2; i < n; i++)
- {
- d = gcd(d, vc[i]);
- }
- if (v % d == 0)
- {
- cout << "YES";
- }
- else
- {
- cout << "NO";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement