結果

問題 No.1330 Multiply or Divide
ユーザー ineedyourlovepineedyourlovep
提出日時 2021-01-08 22:44:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 774 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 172,076 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 04:12:58
合計ジャッジ時間 4,982 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n, m, p;
    cin >> n >> m >> p;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    int cnt = 0;
    ll mx = 0;
    int mx_index = -1;
    rep(i, 0, n){
        if(mx < a[i]%p){
            mx = a[i]%p;
            mx_index = i;
        }
    }
    if(a[n-1] > m){
        cout << 0 << endl;
        return 0;
    }
    if(mx <= 0){
        cout << -1 << endl;
        return 0;
    }
    ll x = 1;
    while(x <= m){
        cnt++;
        if(x*a[n-1] > m) break;
        else if(x%p == 0) x /= p;
        else x *= a[mx_index];
    }
    cout << cnt << endl;
    return 0;
}
0