結果

問題 No.1330 Multiply or Divide
ユーザー definedefine
提出日時 2021-01-08 22:18:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,227 bytes
コンパイル時間 2,470 ms
コンパイル使用メモリ 198,684 KB
実行使用メモリ 5,168 KB
最終ジャッジ日時 2023-08-10 12:30:01
合計ジャッジ時間 4,912 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 24 ms
4,928 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 20 ms
4,940 KB
testcase_07 AC 94 ms
4,944 KB
testcase_08 AC 32 ms
5,028 KB
testcase_09 AC 36 ms
4,928 KB
testcase_10 AC 32 ms
4,940 KB
testcase_11 AC 29 ms
5,004 KB
testcase_12 AC 32 ms
4,928 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 28 ms
4,948 KB
testcase_19 AC 28 ms
4,944 KB
testcase_20 AC 29 ms
4,972 KB
testcase_21 AC 28 ms
5,036 KB
testcase_22 AC 29 ms
5,096 KB
testcase_23 AC 31 ms
4,928 KB
testcase_24 AC 2 ms
4,384 KB
testcase_25 AC 2 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,384 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 2 ms
4,384 KB
testcase_31 AC 2 ms
4,384 KB
testcase_32 AC 2 ms
4,384 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 22 ms
4,528 KB
testcase_35 AC 7 ms
4,380 KB
testcase_36 AC 20 ms
4,412 KB
testcase_37 AC 17 ms
4,400 KB
testcase_38 AC 11 ms
4,380 KB
testcase_39 AC 9 ms
4,380 KB
testcase_40 AC 10 ms
4,384 KB
testcase_41 AC 6 ms
4,384 KB
testcase_42 AC 16 ms
4,380 KB
testcase_43 AC 18 ms
4,384 KB
testcase_44 AC 23 ms
5,040 KB
testcase_45 AC 25 ms
5,168 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