結果

問題 No.1330 Multiply or Divide
ユーザー chocoruskchocorusk
提出日時 2021-01-09 16:50:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,272 bytes
コンパイル時間 1,174 ms
コンパイル使用メモリ 128,616 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-29 00:47:52
合計ジャッジ時間 4,483 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 69 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 38 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 87 ms
6,940 KB
testcase_09 AC 90 ms
6,944 KB
testcase_10 AC 86 ms
6,940 KB
testcase_11 AC 84 ms
6,940 KB
testcase_12 AC 87 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 81 ms
6,944 KB
testcase_19 AC 81 ms
6,944 KB
testcase_20 AC 81 ms
6,944 KB
testcase_21 AC 80 ms
6,944 KB
testcase_22 AC 80 ms
6,940 KB
testcase_23 AC 89 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 60 ms
6,940 KB
testcase_35 AC 18 ms
6,940 KB
testcase_36 AC 55 ms
6,944 KB
testcase_37 AC 49 ms
6,944 KB
testcase_38 AC 31 ms
6,940 KB
testcase_39 AC 22 ms
6,940 KB
testcase_40 AC 26 ms
6,940 KB
testcase_41 AC 15 ms
6,940 KB
testcase_42 AC 45 ms
6,944 KB
testcase_43 AC 52 ms
6,944 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    ll m, p; cin>>m>>p;
    ll a[200020];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    ll mx=*max_element(a, a+n);
    if(mx>m){
        cout<<1<<endl;
        return 0;
    }
    ll x[30];
    fill(x, x+30, 1);
    for(int i=0; i<n; i++){
        int c=0;
        ll b=a[i];
        while(b%p==0){
            b/=p;
            c++;
        }
        x[c]=max(x[c], b);
    }
    ll dp[30]={};
    dp[0]=1;
    for(int i=0; i<30; i++){
        for(int j=0; i+j<30; j++){
            dp[i+j]=max(dp[i+j], dp[i]*x[j]);
        }
    }
    for(int i=0; i<30; i++){
        if(dp[i]>m/mx){
            cout<<i+2<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}
0