結果

問題 No.1250 汝は倍数なりや?
ユーザー weaken
提出日時 2020-10-11 12:54:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,002 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 199,728 KB
最終ジャッジ日時 2025-01-15 06:35:12
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
using namespace std;

vector<int> divEnumeration(int num) {
  vector<int> res;
  if (num < 2) {
    res.emplace_back(1);
    return res;
  }

  int mod = 2;
  while (mod * mod <= num) {
    if (num % mod == 0) {
      res.emplace_back(mod);
      num /= mod;
    } else {
      if (mod == 2) {
        mod++;
      } else {
        mod += 2;
      }
    }
  }

  res.emplace_back(num);
  return res;
}

int main() {
  fastIO;
  int n, h;
  cin >> n >> h;

  int cnt = 0;
  set<int> divs;
  for (const auto mod : divEnumeration(h)) {
    if (divs.find(mod) == divs.end()) {
      divs.insert(mod);
    }
    cnt++;
  }

  for (int i = 0, num; i < n; ++i) {
    cin >> num;
    for (const auto mod : divEnumeration(num)) {
      if (divs.find(mod) != divs.end()) {
        cnt--;
      }
    }

    if (cnt <= 0) {
      cout << "YES" << '\n';
      return 0;
    }
  }

  cout << "NO" << '\n';
  return 0;
}
0