結果
| 問題 |
No.2682 Visible Divisible
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-04-26 14:41:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 155 ms / 2,000 ms |
| コード長 | 782 bytes |
| コンパイル時間 | 281 ms |
| コンパイル使用メモリ | 41,600 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-14 03:16:58 |
| 合計ジャッジ時間 | 5,132 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
/* -*- 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;
}
tnakao0123