結果
問題 | No.1250 汝は倍数なりや? |
ユーザー |
![]() |
提出日時 | 2020-10-09 21:29:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 91 ms / 1,000 ms |
コード長 | 1,604 bytes |
コンパイル時間 | 1,895 ms |
コンパイル使用メモリ | 200,652 KB |
最終ジャッジ日時 | 2025-01-15 03:58:38 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
#include <bits/stdc++.h>//#include <atcoder/all>using namespace std;//using namespace atcoder;//g++ hoge.cpp (-std=c++17) -I . で実行#pragma GCC target("avx")#pragma GCC optimize("O3")#pragma GCC optimize("unroll-loops")typedef long long ll;typedef pair<ll,ll> prl;typedef vector<ll> vcl;typedef map<ll,ll> mapl;typedef unordered_map<ll,ll> umap;#define pb push_back#define all(v) v.begin(), v.end()#define rep(i,a,b) for(ll i=a;i<=b;i++)#define repi(i,a,b) for(int i=a;i<=b;i++)#define repr(i,a,b) for(ll i=a;i>=b;i--)#define reps(i,v) for(ll i=0;i<v.size();i++)template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }const ll mod = 1e9+7;//Prime_Factorizationvector<prl> prime_fact(ll n){vector<prl> p;ll nc = n;for(ll i = 2; i * i <= n; i++){if(nc % i !=0) continue;ll c = 0;while(nc % i == 0) c++, nc /= i;p.push_back({i, c});}if(nc > 1) p.push_back({nc, 1});return p;}int main() {// your code goes herell n,h;cin >> n >> h;vector<prl> ps;ps = prime_fact(h);rep(i,1,n){ll a;cin >> a;for(ll i=0; i<ps.size(); i++){if(ps[i].second==0) continue;while(ps[i].second>0 && a%ps[i].first==0){a/=ps[i].first;ps[i].second--;}}}for(auto pr : ps){if(pr.second>0){cout << "NO" << endl;return 0;}}cout << "YES" << endl;return 0;}