結果
問題 |
No.1250 汝は倍数なりや?
|
ユーザー |
![]() |
提出日時 | 2024-01-24 00:35:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 96 ms / 1,000 ms |
コード長 | 809 bytes |
コンパイル時間 | 2,033 ms |
コンパイル使用メモリ | 201,952 KB |
最終ジャッジ日時 | 2025-02-18 22:28:59 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n, h; cin >> n >> h; map<int, int> mp; for (int i = 2; i * i <= h; i++) { while (h % i == 0) h /= i, mp[i]++; } if (h != 1) mp[h]++; vector<int> a(n); rep(i, n) cin >> a[i]; for (int _x : a) { int x = abs(_x); if (x == 0) { cout << "YES" << endl; return 0; } for (auto&& [p, cnt] : mp) { while (x % p == 0) x /= p, cnt--; } } for (auto&& [p, cnt] : mp) { if (cnt > 0) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }