結果

問題 No.1330 Multiply or Divide
ユーザー 👑 deuteridayodeuteridayo
提出日時 2021-01-17 04:34:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,053 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 178,708 KB
実行使用メモリ 15,856 KB
最終ジャッジ日時 2023-08-19 10:33:51
合計ジャッジ時間 8,699 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 4 ms
7,620 KB
testcase_04 AC 4 ms
7,352 KB
testcase_05 AC 4 ms
7,592 KB
testcase_06 AC 55 ms
15,516 KB
testcase_07 AC 169 ms
15,712 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 110 ms
15,688 KB
testcase_19 AC 110 ms
15,712 KB
testcase_20 AC 110 ms
15,836 KB
testcase_21 AC 109 ms
15,568 KB
testcase_22 AC 110 ms
15,712 KB
testcase_23 AC 105 ms
15,512 KB
testcase_24 AC 4 ms
7,596 KB
testcase_25 AC 4 ms
7,612 KB
testcase_26 WA -
testcase_27 AC 5 ms
7,412 KB
testcase_28 AC 4 ms
7,452 KB
testcase_29 AC 3 ms
7,644 KB
testcase_30 AC 3 ms
7,540 KB
testcase_31 AC 4 ms
7,472 KB
testcase_32 AC 4 ms
7,560 KB
testcase_33 AC 4 ms
7,676 KB
testcase_34 AC 84 ms
13,400 KB
testcase_35 AC 25 ms
9,352 KB
testcase_36 AC 73 ms
12,804 KB
testcase_37 AC 65 ms
12,200 KB
testcase_38 AC 41 ms
10,532 KB
testcase_39 AC 30 ms
9,680 KB
testcase_40 AC 36 ms
10,176 KB
testcase_41 AC 19 ms
9,244 KB
testcase_42 AC 61 ms
11,932 KB
testcase_43 AC 69 ms
12,668 KB
testcase_44 AC 102 ms
15,644 KB
testcase_45 AC 137 ms
15,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
// using namespace atcoder;
using lint = long long;
#define endl '\n'
lint const mod = 1e9+7;
//long const mod = 998244353;
map<lint,lint>dp;
lint maxx;

    lint n,m,p;
    lint a[200000];
    vector<vector<lint>>pa(200000);
lint search(lint x){
    if(x >= maxx)return 1;
    if(dp[x] != 0)return dp[x];

    lint tmp = 0;
    for(int i=0;i<n;i++){
        if(pa[i][0] > 1){
            tmp = max(tmp, search(x * pa[i][0]) + pa[i][1]);
        }
    }
    return dp[x] = tmp;

    
}

int main(){
    cin >> n >> m >> p;
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    maxx = ((m+1)/a[n-1]);
    while(maxx * a[n-1] <= m)maxx++;
    for(int i=0;i<n;i++){
        pa[i] = {a[i], 1};
        while(pa[i][0] % p == 0){
            pa[i][0] /= p;
            pa[i][1]++;
        }
    }
    bool chk = false;
    for(int i=0;i<n;i++){
        if(pa[i][0] > 1)chk = true;
    }
    if(!chk){
        cout << -1 << endl;
        return 0;
    }
    cout << search(1) << endl;
}
0