結果

問題 No.1330 Multiply or Divide
ユーザー shiomusubi496shiomusubi496
提出日時 2021-01-08 21:47:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 536 bytes
コンパイル時間 1,277 ms
コンパイル使用メモリ 168,204 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 02:38:04
合計ジャッジ時間 4,089 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 59 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 32 ms
5,376 KB
testcase_07 AC 115 ms
5,376 KB
testcase_08 AC 73 ms
5,376 KB
testcase_09 AC 76 ms
5,376 KB
testcase_10 AC 75 ms
5,376 KB
testcase_11 AC 71 ms
5,376 KB
testcase_12 AC 73 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 69 ms
5,376 KB
testcase_19 AC 69 ms
5,376 KB
testcase_20 AC 70 ms
5,376 KB
testcase_21 AC 69 ms
5,376 KB
testcase_22 AC 70 ms
5,376 KB
testcase_23 WA -
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 53 ms
5,376 KB
testcase_35 AC 16 ms
5,376 KB
testcase_36 AC 46 ms
5,376 KB
testcase_37 AC 41 ms
5,376 KB
testcase_38 AC 26 ms
5,376 KB
testcase_39 AC 19 ms
5,376 KB
testcase_40 AC 22 ms
5,376 KB
testcase_41 AC 12 ms
5,376 KB
testcase_42 AC 38 ms
5,376 KB
testcase_43 AC 44 ms
5,376 KB
testcase_44 AC 33 ms
5,376 KB
testcase_45 AC 35 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF=1e18;
signed main(){
    int N,M,P,mx=0;cin>>N>>M>>P;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        mx=max(mx,A[i]);
    }
    int ans=INF,m=(M+mx-1)/mx;
    for(int i=0;i<N;i++){
        int a=1,b=1,cnt=1;
        while(A[i]%P==0)A[i]/=P,a++;
        if(A[i]==1){
            if(m==1)ans=1;
            continue;
        }
        while(b<m)b*=A[i],cnt+=a;
        ans=min(ans,cnt);
    }
    cout<<(ans==INF?-1:ans)<<endl;
}
0