結果

問題 No.1250 汝は倍数なりや?
ユーザー linuxmetel
提出日時 2020-10-09 22:10:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 108 ms / 1,000 ms
コード長 573 bytes
コンパイル時間 1,762 ms
コンパイル使用メモリ 191,860 KB
最終ジャッジ日時 2025-01-15 04:50:01
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int gcd(int x, int y) {
    if(x % y == 0) {
      return y;
    } else {
      return gcd(y, x % y); 
        //x%y==0でないときはユーグリットの互除法を使って再帰的に関数を呼び出す。
    }
}

int main() {
  int n, h;
  cin >> n >> h;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a == 0) {
      cout << "YES" << endl;
      return 0;
    }
    h /= gcd(h, a);
    if (h == 1) {
      goto yes;
    }
  }
  cout << "NO" << endl;
  return 0;
 yes:
  cout << "YES" << endl;
}
0