結果
問題 | No.1250 汝は倍数なりや? |
ユーザー |
![]() |
提出日時 | 2023-08-28 14:58:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 113 ms / 1,000 ms |
コード長 | 622 bytes |
コンパイル時間 | 895 ms |
コンパイル使用メモリ | 102,432 KB |
最終ジャッジ日時 | 2025-02-16 15:21:11 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
#include<iostream> #include<map> #include<vector> #include <algorithm> #include<math.h> #include <iomanip> #include<set> #include <numeric> #include<string> using namespace std; int main() { int n, h, cnt = 0; cin >> n >> h; vector<int> a(n), b(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) b[i] = gcd(a[i], h); while (h != 1){ if (cnt == n) { cout << "NO" << endl; return 0; } if (!(h%b[cnt])) h /= b[cnt]; int t = gcd(h, b[cnt]); if (t != 1) h /= t; cnt++; } cout << "YES" << endl; }