結果

問題 No.1250 汝は倍数なりや?
ユーザー mdstoymdstoy
提出日時 2020-10-09 23:26:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 1,000 ms
コード長 2,733 bytes
コンパイル時間 2,271 ms
コンパイル使用メモリ 205,220 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 19:50:17
合計ジャッジ時間 4,990 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

map<ll, ll> prime_factorization(ll n) {
    map<ll, ll> m;
    ll x = n;
    ll d = 2;
    while (x > 1 && d * d <= n) {
        if (x % d == 0) {
            m[d]++;
            x /= d;
        } else {
            d++;
        }
    }
    if (x != 1) m[x]++;
    return m;
}

void solve() {
    int n, h;
    cin >> n >> h;
    auto g = prime_factorization(h);
    // bool positive = true;
    REP(i, n) {
        int a;
        cin >> a;
        if (a == 0) {
            cout << "YES" << endl;
            return;
        } else if (a < 0) {
            // positive = !positive;
            a = abs(a);
        }
        for (auto e : g) {
            int c = 0;
            REP(j, e.second) {
                if (a % e.first == 0) {
                    a /= e.first;
                    c++;
                }
            }
            g[e.first] -= c;
        }
    }
    // if (!positive) {
    //     cout << "NO" << endl;
    //     return;
    // }
    for (auto q : g) {
        if (q.second > 0) {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}
0