Advertisement
ke_timofeeva7

g тч

Jun 7th, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <memory.h>
  7. #include <stdio.h>
  8. #include <stack>
  9. #include <deque>
  10. #include <queue>
  11. #include <vector>
  12. #include <set>
  13. #include <iterator>
  14. #include <map>
  15. #include <iomanip>
  16. #include <unordered_set>
  17. #define int long long
  18. #define sp system("pause")
  19. #define pb push_back
  20. #define double long double
  21. #define endl "\n"
  22. #define un unsigned
  23. #define INF 1000000009
  24. #define pii pair<int, int>
  25. #define un unsigned
  26. #define all(v) v.begin(), v.end()
  27. using namespace std;
  28.  
  29. int n1;
  30.  
  31. istream& operator >> (istream& in, vector<int>& a)
  32. {
  33.     for (int i = 0; i < n1; i++)
  34.     {
  35.         in >> a[i];
  36.     }
  37.  
  38.     return in;
  39. }
  40.  
  41. ostream& operator << (ostream& out, vector<char>& a)
  42. {
  43.     for (int i = n1 - 1; i > -1; i--)
  44.     {
  45.         out << a[i];
  46.     }
  47.  
  48.     return out;
  49. }
  50.  
  51. int gcd(un int a, un int b)
  52. {
  53.     if (a == 0 || b == 0)
  54.     {
  55.         return a + b;
  56.     }
  57.  
  58.     return gcd(b % a, a);
  59. }
  60.  
  61.  
  62. void exteded_gcd(int a, int b, int& x, int& y)
  63. {
  64.     if (a == 0)
  65.     {
  66.         x = 0;
  67.         y = 1;
  68.        
  69.         return;
  70.     }
  71.  
  72.     int x1, y1;
  73.  
  74.     exteded_gcd(b % a, a, x1, y1);
  75.  
  76.     x = y1 - (b / a) * x1;
  77.     y = x1;
  78.  
  79.     return;
  80. }
  81.  
  82. bool isPrime(int a)
  83. {
  84.     int d = 2;
  85.  
  86.     if (a == 1)
  87.     {
  88.         return false;
  89.     }
  90.  
  91.     while (d * d <= a)
  92.     {
  93.         if (a % d == 0)
  94.         {
  95.             return false;
  96.         }
  97.  
  98.         d++;
  99.     }
  100.  
  101.     return true;
  102. }
  103.  
  104. signed main()
  105. {
  106.     ios_base::sync_with_stdio(0);
  107.     cin.tie(0);
  108.     cout.tie(0);
  109.  
  110.     int n, v;
  111.     cin >> n >> v;
  112.  
  113.     vector <int> vc(n);
  114.  
  115.     for (int i = 0; i < n; i++)
  116.     {
  117.         cin >> vc[i];
  118.     }
  119.  
  120.     if (n == 1)
  121.     {
  122.         if (vc[0] != v)
  123.         {
  124.             cout << "NO";
  125.         }
  126.         else
  127.         {
  128.             cout << "YES";
  129.         }
  130.  
  131.         return 0;
  132.     }
  133.  
  134.     int d = gcd(vc[0], vc[1]);
  135.  
  136.     for (int i = 2; i < n; i++)
  137.     {
  138.         d = gcd(d, vc[i]);
  139.     }
  140.  
  141.     if (v % d == 0)
  142.     {
  143.         cout << "YES";
  144.     }
  145.     else
  146.     {
  147.         cout << "NO";
  148.     }
  149.  
  150.     return 0;
  151.    
  152. }
  153.  
  154.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement