結果

問題 No.1250 汝は倍数なりや?
ユーザー firiexpfiriexp
提出日時 2020-10-09 21:38:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 1,000 ms
コード長 1,514 bytes
コンパイル時間 1,160 ms
コンパイル使用メモリ 112,320 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 15:41:39
合計ジャッジ時間 3,371 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 30 ms
4,376 KB
testcase_34 AC 20 ms
4,380 KB
testcase_35 AC 24 ms
4,376 KB
testcase_36 AC 28 ms
4,380 KB
testcase_37 AC 15 ms
4,380 KB
testcase_38 AC 17 ms
4,376 KB
testcase_39 AC 19 ms
4,376 KB
testcase_40 AC 19 ms
4,376 KB
testcase_41 AC 18 ms
4,376 KB
testcase_42 AC 13 ms
4,380 KB
testcase_43 AC 29 ms
4,380 KB
testcase_44 AC 12 ms
4,380 KB
testcase_45 AC 26 ms
4,376 KB
testcase_46 AC 12 ms
4,376 KB
testcase_47 AC 20 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

vector<int> get_prime(int n){
    if(n <= 1) return vector<int>();
    vector<bool> is_prime(n+1, true);
    vector<int> prime;
    is_prime[0] = is_prime[1] = 0;
    for (int i = 2; i <= n; ++i) {
        if(is_prime[i]) prime.emplace_back(i);
        for (auto &&j : prime){
            if(i*j > n) break;
            is_prime[i*j] = false;
            if(i % j == 0) break;
        }
    }
    return prime;
}
const auto primes = get_prime(65535);

template<class T>
map<T, int> prime_factor(T n){
    map<T, int> res;
    for (auto &&i : primes) {
        while (n % i == 0){
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n]++;
    return res;
}

int main() {
    int n, h;
    cin >> n >> h;
    vector<int> a(n);
    for (auto &&i : a) {
        scanf("%d", &i), i = abs(i);
        if(!i) return puts("YES"), 0;
    }
    auto d = prime_factor(h);
    for (auto &[x, p] : d) {
        int val = 0;
        for (auto &&i : a) {
            while(i%x == 0) {
                val++;
                i /= x;
            }
        }
        if(val < p) return puts("NO"), 0;
    }
    puts("YES");
    return 0;
}
0