結果

問題 No.1330 Multiply or Divide
ユーザー ocvret_ocvret_
提出日時 2021-01-08 22:04:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 712 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 166,012 KB
実行使用メモリ 6,424 KB
最終ジャッジ日時 2023-08-10 12:27:00
合計ジャッジ時間 5,230 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 67 ms
6,188 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 38 ms
6,280 KB
testcase_07 AC 139 ms
6,412 KB
testcase_08 AC 83 ms
6,184 KB
testcase_09 AC 88 ms
6,244 KB
testcase_10 AC 84 ms
6,256 KB
testcase_11 AC 81 ms
6,200 KB
testcase_12 AC 83 ms
6,204 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 80 ms
6,192 KB
testcase_19 AC 80 ms
6,200 KB
testcase_20 AC 79 ms
6,200 KB
testcase_21 AC 80 ms
6,316 KB
testcase_22 AC 80 ms
6,248 KB
testcase_23 AC 86 ms
6,136 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 60 ms
5,372 KB
testcase_35 AC 17 ms
4,376 KB
testcase_36 AC 53 ms
5,360 KB
testcase_37 AC 48 ms
4,900 KB
testcase_38 AC 31 ms
4,380 KB
testcase_39 AC 22 ms
4,380 KB
testcase_40 AC 26 ms
4,380 KB
testcase_41 AC 13 ms
4,376 KB
testcase_42 AC 44 ms
4,576 KB
testcase_43 AC 51 ms
4,868 KB
testcase_44 AC 39 ms
6,192 KB
testcase_45 AC 40 ms
6,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>

using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

int main(){
  
  ll n,m,p;
  cin >> n >> m >> p;
  ll mx = 0;
  vector<ll> v(n);
  vector<ll> nv(n);
  rep(i,n){
    cin >> v[i];
    mx = max(mx,v[i]);
    while(v[i]%p == 0)v[i] /= p,nv[i]++;
  }
  ll res = MOD;
  rep(i,n){
    if(v[i] == 1)continue;
    ll k = mx;
    ll g = 1;
    while(k <= m)k *= v[i],g += nv[i]+1;
    res = min(res,g);
  }
  if(mx > m)res = 1;
  cout << (res != MOD ? res : -1) << "\n";


  return 0;
}
0