結果

問題 No.1330 Multiply or Divide
ユーザー pyonthpyonth
提出日時 2021-01-08 21:36:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,334 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 201,892 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 02:20:34
合計ジャッジ時間 3,920 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 20 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 19 ms
6,944 KB
testcase_07 AC 83 ms
6,940 KB
testcase_08 AC 29 ms
6,940 KB
testcase_09 AC 32 ms
6,944 KB
testcase_10 AC 28 ms
6,944 KB
testcase_11 AC 27 ms
6,944 KB
testcase_12 AC 28 ms
6,940 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 25 ms
6,940 KB
testcase_19 AC 26 ms
6,944 KB
testcase_20 AC 25 ms
6,944 KB
testcase_21 AC 25 ms
6,940 KB
testcase_22 AC 24 ms
6,940 KB
testcase_23 AC 26 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 1 ms
6,944 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,944 KB
testcase_34 AC 19 ms
6,940 KB
testcase_35 AC 7 ms
6,944 KB
testcase_36 AC 17 ms
6,940 KB
testcase_37 AC 15 ms
6,940 KB
testcase_38 AC 10 ms
6,940 KB
testcase_39 AC 7 ms
6,940 KB
testcase_40 AC 8 ms
6,940 KB
testcase_41 AC 5 ms
6,948 KB
testcase_42 AC 14 ms
6,944 KB
testcase_43 AC 16 ms
6,944 KB
testcase_44 AC 18 ms
6,940 KB
testcase_45 AC 19 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr int inf = 1e9 + 10;
constexpr ll INF = (ll)4e18 + 10;
constexpr int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
constexpr int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
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;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int n;
    ll m, p;
    cin >> n >> m >> p;
    ll a[n];
    ll mx = 0;
    vector<int> cnt(n);
    rep(i, n) {
        cin >> a[i];
        chmax(mx, a[i]);
        while (a[i] % p == 0) {
            cnt[i]++;
            a[i] /= p;
        }
    }

    ll M = 0, C = 0;
    rep(i, n) if (chmax(M, a[i])) C = cnt[i];

    if (M == 1) {
        if (mx > m)
            puts("1");
        else
            puts("-1");
        return 0;
    }

    ll now = 1, ans = 0;
    while (now * mx <= m) {
        now *= M;
        ans += C + 1;
    }

    cout << ans + 1 << endl;

    return 0;
}
0