結果
| 問題 | No.1250 汝は倍数なりや? | 
| コンテスト | |
| ユーザー |  kyo1 | 
| 提出日時 | 2020-11-05 01:14:46 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 30 ms / 1,000 ms | 
| コード長 | 1,349 bytes | 
| コンパイル時間 | 2,466 ms | 
| コンパイル使用メモリ | 196,872 KB | 
| 最終ジャッジ日時 | 2025-01-15 19:52:06 | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 49 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
class Prime {
 public:
  template <typename T>
  static bool is_prime(T n) {
    if (n == 0 || n == 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for (T i = 3; i * i < n + 1; i += 2) {
      if (n % i == 0) return false;
    }
    return true;
  }
  template <typename T>
  static std::vector<T> factor(T n) {
    std::vector<T> res;
    for (T i = 2; i * i < n + 1; i++) {
      while (n % i == 0) {
        n /= i;
        res.emplace_back(i);
      }
    }
    if (n != 1) res.emplace_back(n);
    return res;
  }
  template <typename T>
  static T totient(T n) {
    T res = 1;
    std::vector<T> primes = factor(n);
    std::map<T, int> mp;
    for (T p : primes) {
      mp[p]++;
    }
    for (const auto& [p, c] : mp) {
      res *= pow(p, c - 1) * (p - 1);
    }
    return res;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, H;
  cin >> N >> H;
  vector<int> A(N);
  for (auto&& e : A) {
    cin >> e;
  }
  vector<int> primes = Prime::factor(H);
  for (auto&& p : primes) {
    bool ok = false;
    for (auto&& a : A) {
      if (a % p == 0) {
        a /= p;
        ok = true;
        break;
      }
    }
    if (!ok) {
      cout << "NO" << '\n';
      return 0;
    }
  }
  cout << "YES" << '\n';
  return 0;
}
            
            
            
        