結果

問題 No.1330 Multiply or Divide
ユーザー definedefine
提出日時 2021-01-08 22:18:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,227 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 199,792 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 05:46:33
合計ジャッジ時間 4,365 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 23 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 20 ms
5,376 KB
testcase_07 AC 95 ms
5,376 KB
testcase_08 AC 31 ms
5,376 KB
testcase_09 AC 34 ms
5,376 KB
testcase_10 AC 31 ms
5,376 KB
testcase_11 AC 28 ms
5,376 KB
testcase_12 AC 31 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 1 ms
5,376 KB
testcase_18 AC 27 ms
5,376 KB
testcase_19 AC 27 ms
5,376 KB
testcase_20 AC 27 ms
5,376 KB
testcase_21 AC 27 ms
5,376 KB
testcase_22 AC 27 ms
5,376 KB
testcase_23 AC 28 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 20 ms
5,376 KB
testcase_35 AC 7 ms
5,376 KB
testcase_36 AC 18 ms
5,376 KB
testcase_37 AC 16 ms
5,376 KB
testcase_38 AC 11 ms
5,376 KB
testcase_39 AC 8 ms
5,376 KB
testcase_40 AC 10 ms
5,376 KB
testcase_41 AC 5 ms
5,376 KB
testcase_42 AC 15 ms
5,376 KB
testcase_43 AC 17 ms
5,376 KB
testcase_44 AC 23 ms
5,376 KB
testcase_45 AC 25 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 2 "/home/defineprogram/Desktop/Library/template/template.cpp"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i < n; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
#define len(s) (ll) s.size()

template <class T, class U>
inline bool chmin(T &a, U b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T, class U>
inline bool chmax(T &a, U b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
constexpr ll inf = 3e18;
#line 2 "main.cpp"

int N;
ll M,p;
ll A[1<<18];
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin>>N>>M>>p;
    ll mx=0;
    rep(i,N){
        cin>>A[i];
        chmax(mx,A[i]);
    }
    int ans=1e9;
    rep(i,N){
        int cnt=1;
        while(A[i]%p==0){
            A[i]/=p;cnt++;
        }
        if(A[i]!=1){
            int cc=0,now=1;
            while(now*mx<=M){
                now*=A[i];
                cc+=cnt;
            }
            chmin(ans,cc+1);
        }
    }
    if(ans==1e9)cout<<"-1\n";
    else cout<<ans<<"\n";
}
0