結果

問題 No.1250 汝は倍数なりや?
ユーザー noritakenoritake
提出日時 2020-10-09 22:28:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,623 bytes
コンパイル時間 1,408 ms
コンパイル使用メモリ 173,124 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-27 18:16:39
合計ジャッジ時間 4,797 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all> // NOTE: AtCoderライブラリ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
// using namespace atcoder; // NOTE: AtCoderライブラリ
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int, int> pii;
// #define INF __INT32_MAX__
// #define INF 1e9
// #define LINF __LONG_LONG_MAX__


int main() {
    int N, H; cin >> N >> H;
    
    map<int, int> hg;
    for (int i = 2; i <= sqrt(H); i++) {
        if (H % i != 0) continue;
        int ext = 0;
        while (H % i == 0) {
            ext++;
            H /= i;
        }
        hg[i] += ext;
    }
    if (H != 1) hg[H]++;

// for (auto x : hg) { cout << x.first << "^" << x.second << endl; }

    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        if (A[i] == 1) continue;

        bool ok = true;
        for (auto x : hg) {
            if (x.second < 1) continue;
            if (A[i] % x.first != 0) continue;
            while (A[i] % x.first == 0) {
                if (x.second < 1) break;
                A[i] /= x.first;
                hg[x.first]--;
            }
            ok = false;
        }

        if (ok) {
            cout << "YES" << endl;
            return 0;
        }
    }


    bool ok = true;
    for (auto x : hg) {
        if (x.second > 0) ok = false;
    }

// for (auto x : hg) { cout << x.first << "^" << x.second << endl; }

    if (ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

0