結果

問題 No.1250 汝は倍数なりや?
ユーザー YamaKasa
提出日時 2020-10-09 23:22:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 836 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 174,280 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-20 14:16:40
合計ジャッジ時間 4,267 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 TLE * 1 -- * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int N;
    int H;
    cin >> N >> H;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] < 0) A[i] = -A[i];
    }
    map<int, int> m;
    for (int i = 2; i * i <= H; i++) {
        while (H % i == 0) {
            m[i]++;
            H /= i;
        }
    }
    m[H]++;
    for (auto it = m.begin(); it != m.end(); it++) {
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            while (A[i] % it->first == 0) {
                cnt++;
                A[i] /= it->first;
            }
            if (cnt >= it->second) break;
        }
        //cout << cnt << "\n";
        if (cnt < it->second) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}
0