結果
問題 | No.1250 汝は倍数なりや? |
ユーザー | tokusakurai |
提出日時 | 2020-10-09 21:26:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 89 ms / 1,000 ms |
コード長 | 2,436 bytes |
コンパイル時間 | 2,101 ms |
コンパイル使用メモリ | 198,164 KB |
最終ジャッジ日時 | 2025-01-15 03:54:48 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i <= n; i++) #define rep3(i, x, n) for(int i = x; i >= n; i--) #define elif else if #define sp(x) fixed << setprecision(x) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() using ll = long long; using pii = pair<int, int>; using pil = pair<int, ll>; using pli = pair<ll, int>; using pll = pair<ll, ll>; const int MOD = 1000000007; //const int MOD = 998244353; const int inf = (1<<30)-1; const ll INF = (1LL<<60)-1; const double pi = acos(-1.0); const double EPS = 1e-10; template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;}; template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;}; template<typename T> struct Prime{ Prime() {} vector<T> divisors(const T &n) const{ vector<T> ret; for(T i = 1; i*i <= n; i++){ if(n%i == 0){ ret.pb(i); if(i*i != n) ret.pb(n/i); } } //sort(all(ret)); return ret; } vector<pair<T, int>> prime_factor(T n) const{ vector<pair<T, int>> ret; for(T i = 2; i*i <= n; i++){ int cnt = 0; while(n%i == 0) cnt++, n /= i; if(cnt > 0) ret.eb(i, cnt); } if(n > 1) ret.eb(n, 1); return ret; } bool is_prime(const T &n) const{ if(n == 1) return false; for(T i = 2; i*i <= n; i++){ if(n%i == 0) return false; } return true; } vector<bool> Eratosthenes(const int &n) const{ vector<bool> ret(n+1, true); if(n >= 0) ret[0] = false; if(n >= 1) ret[1] = false; for(int i = 2; i*i <= n; i++){ if(!ret[i]) continue; for(int j = 2; i*j <= n; j++) ret[i*j] = false; } return ret; } }; int main(){ Prime<int> P; int N, H; cin >> N >> H; vector<pii> v = P.prime_factor(H); rep(i, N){ int A; cin >> A; if(A == 0) {cout << "YES" << endl; return 0;} A = abs(A); for(auto &e: v){ while(e.second > 0 && A%e.first == 0) e.second--, A /= e.first; } } bool flag = true; for(auto &e: v) if(e.second > 0) flag = false; cout << (flag? "YES" : "NO") << endl; }