結果
問題 | No.1250 汝は倍数なりや? |
ユーザー |
![]() |
提出日時 | 2021-03-11 01:40:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 905 bytes |
コンパイル時間 | 743 ms |
コンパイル使用メモリ | 75,680 KB |
実行使用メモリ | 13,636 KB |
最終ジャッジ日時 | 2024-10-12 16:18:22 |
合計ジャッジ時間 | 3,727 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 TLE * 1 -- * 30 |
ソースコード
#include <iostream> #include <vector> using namespace std; using ll = long long int; using P = pair<int, int>; int main(){ ll n, h; cin >> n >> h; vector<ll> a(n); for(auto &p: a) cin >> p; vector<P> hfactor; for(int i = 2; h > 1; i++){ if(h % i == 0){ int cnt = 0; while(h % i == 0){ cnt++; h /= i; } hfactor.push_back(make_pair(i, cnt)); } } vector<int> countfac(hfactor.size(), 0); for(auto p: a){ for(int i = 0; i < hfactor.size(); i++){ while(p % hfactor[i].first == 0){ countfac[i]++; p /= hfactor[i].first; } } } string ans = "YES"; for(int i = 0; i < hfactor.size(); i++){ if(hfactor[i].second > countfac[i]) ans = "NO"; } cout << ans << endl; return 0; }