結果

問題 No.1250 汝は倍数なりや?
ユーザー hedwig100hedwig100
提出日時 2020-10-10 20:00:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 1,000 ms
コード長 2,262 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 174,736 KB
実行使用メモリ 4,832 KB
最終ジャッジ日時 2023-09-27 22:34:49
合計ジャッジ時間 3,516 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 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,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 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,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 33 ms
4,832 KB
testcase_34 AC 25 ms
4,380 KB
testcase_35 AC 27 ms
4,628 KB
testcase_36 AC 33 ms
4,628 KB
testcase_37 AC 17 ms
4,380 KB
testcase_38 AC 18 ms
4,380 KB
testcase_39 AC 24 ms
4,380 KB
testcase_40 AC 22 ms
4,376 KB
testcase_41 AC 19 ms
4,516 KB
testcase_42 AC 15 ms
4,380 KB
testcase_43 AC 32 ms
4,608 KB
testcase_44 AC 11 ms
4,376 KB
testcase_45 AC 26 ms
4,616 KB
testcase_46 AC 11 ms
4,376 KB
testcase_47 AC 22 ms
4,380 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_
void debug_out() {cerr << endl;}
template<typename Head,typename... Tail> void debug_out(Head H,Tail... T){cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:",debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl;
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

vector<int> sieve(int n) {
    vector<bool> prime(n + 1,true);
    prime[0] = false;
    prime[1] = false;
    for (int i = 3; i * i <= n; i += 2) {
        if (prime[i]) {
            int j = 2;
            while (i * j <= n) {
                prime[i * j] = false;
                j ++;
            }
        }
    }
    vector<int> ans = {2};
    for (int i = 3; i < n + 1; i += 2) {
        if (prime[i]) ans.push_back(i);
    }
    return ans; 
}

vector<pair<int,int>> factorization(long long N,vector<int>& primes) {
    vector<pair<int,int>> ret;
    for (int p:primes) {
        int power = 0;
        while (N%p == 0) {
            power ++;
            N /= p;
        }
        if (power > 0) ret.emplace_back(p,power);
    }
    if (N > 1) ret.emplace_back(N,1);
    return ret;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll N,H; cin >> N >> H;
    vector<ll> A(N);
    rep(i,N) {
        cin >> A[i];
        if (A[i] == 0) {
            cout << "YES" << '\n';
            return 0;
        }
    }

    auto ps = sieve(100000);
    auto x = factorization(H,ps);
    for (ll a:A) {
        for (P &p:x) {
            while (p.first > 0 && a%p.first == 0) {
                p.second--;
                a /= p.first;
            }
        }
    }
    bool flag = true;
    for (P &p:x) {
        if (p.second > 0) flag = false;
    }
    cout << (flag ? "YES":"NO") << '\n';
    return 0;
}
0