結果

問題 No.2682 Visible Divisible
ユーザー tnakao0123tnakao0123
提出日時 2024-04-26 14:41:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 42,476 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 14:41:32
合計ジャッジ時間 5,149 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
6,816 KB
testcase_01 AC 146 ms
6,944 KB
testcase_02 AC 143 ms
6,940 KB
testcase_03 AC 148 ms
6,944 KB
testcase_04 AC 154 ms
6,940 KB
testcase_05 AC 153 ms
6,944 KB
testcase_06 AC 147 ms
6,940 KB
testcase_07 AC 150 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 152 ms
6,940 KB
testcase_12 AC 155 ms
6,940 KB
testcase_13 AC 148 ms
6,940 KB
testcase_14 AC 153 ms
6,944 KB
testcase_15 AC 149 ms
6,940 KB
testcase_16 AC 147 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2682.cc:  No.2682 Visible Divisible - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;

/* global variables */

ll as[MAX_N];

/* subroutines */

template <typename T>
T gcd(T m, T n) {  // m >= 0, n >= 0
  if (m < n) swap(m, n);
  while (n > 0) {
    T r = m % n;
    m = n;
    n = r;
  }
  return m;
}

/* main */

int main() {
  int n;
  ll k;
  scanf("%d%lld", &n, &k);
  for (int i = 0; i < n; i++) scanf("%lld", as + i);

  for (int i = 0; i < n; i++) as[i] = gcd(k, as[i]);

  ll l = 1;
  for (int i = 0; i < n; i++) {
    ll g = gcd(l, as[i]);
    l = l / g * as[i];
  }

  if (l == k) puts("Yes");
  else puts("No");
  
  return 0;
}
0