結果

問題 No.1330 Multiply or Divide
ユーザー shiomusubi496shiomusubi496
提出日時 2021-01-08 21:59:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 531 bytes
コンパイル時間 1,578 ms
コンパイル使用メモリ 166,136 KB
実行使用メモリ 4,864 KB
最終ジャッジ日時 2023-08-10 12:26:49
合計ジャッジ時間 5,147 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 65 ms
4,864 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 36 ms
4,588 KB
testcase_07 AC 132 ms
4,724 KB
testcase_08 AC 82 ms
4,612 KB
testcase_09 AC 86 ms
4,720 KB
testcase_10 AC 82 ms
4,596 KB
testcase_11 AC 81 ms
4,704 KB
testcase_12 AC 82 ms
4,660 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 77 ms
4,632 KB
testcase_19 AC 78 ms
4,708 KB
testcase_20 AC 77 ms
4,580 KB
testcase_21 AC 78 ms
4,656 KB
testcase_22 AC 79 ms
4,604 KB
testcase_23 AC 85 ms
4,676 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 59 ms
4,380 KB
testcase_35 AC 18 ms
4,376 KB
testcase_36 AC 52 ms
4,380 KB
testcase_37 AC 47 ms
4,376 KB
testcase_38 AC 30 ms
4,380 KB
testcase_39 AC 21 ms
4,384 KB
testcase_40 AC 26 ms
4,380 KB
testcase_41 AC 13 ms
4,380 KB
testcase_42 AC 44 ms
4,380 KB
testcase_43 AC 50 ms
4,380 KB
testcase_44 AC 38 ms
4,604 KB
testcase_45 AC 40 ms
4,556 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;
    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