結果

問題 No.1330 Multiply or Divide
ユーザー chocono2230chocono2230
提出日時 2021-01-08 22:13:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,201 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 201,908 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 03:27:59
合計ジャッジ時間 4,946 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 59 ms
6,944 KB
testcase_02 WA -
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 31 ms
6,940 KB
testcase_07 AC 92 ms
6,940 KB
testcase_08 AC 76 ms
6,940 KB
testcase_09 AC 78 ms
6,944 KB
testcase_10 AC 77 ms
6,940 KB
testcase_11 AC 72 ms
6,940 KB
testcase_12 AC 75 ms
6,940 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 71 ms
6,940 KB
testcase_19 AC 77 ms
6,944 KB
testcase_20 AC 76 ms
6,944 KB
testcase_21 AC 75 ms
6,940 KB
testcase_22 AC 74 ms
6,940 KB
testcase_23 AC 82 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 1 ms
6,944 KB
testcase_29 AC 1 ms
6,944 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 1 ms
6,940 KB
testcase_34 AC 55 ms
6,940 KB
testcase_35 AC 16 ms
6,944 KB
testcase_36 AC 49 ms
6,940 KB
testcase_37 AC 44 ms
6,940 KB
testcase_38 AC 27 ms
6,940 KB
testcase_39 AC 19 ms
6,944 KB
testcase_40 AC 25 ms
6,940 KB
testcase_41 AC 13 ms
6,944 KB
testcase_42 AC 41 ms
6,944 KB
testcase_43 AC 48 ms
6,944 KB
testcase_44 AC 30 ms
6,944 KB
testcase_45 AC 29 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

pair<ll, ll> fc(int a, int p){
  int res = 1;
  while(a % p == 0){
    res++;
    a /= p;
  }
  return {a, res};
}

int main(){
  int n, m, p;
  cin >> n >> m >> p;
  if(m == 1){
    cout << 0 << endl;
    return 0;
  }
  ll now = 1;
  pair<ll, ll> mx(0, 1);
  rep(i, n){
    int in;
    cin >> in;
    now = max((int)now, in);
    auto [a, b] = fc(in, p);
    if(mx.first * b < a*mx.second){
      mx = {a, b};
    }else if(mx.first * b == a*mx.second){
      if(b < mx.second){
        mx = {a, b};
      }
    }
  }
  int ans = 1;
  while(now <= m){
    ll nx = now * mx.first;
    ans += mx.second;
    if(nx <= now){
      ans = -1;
      break;
    }
    now = nx;
  }
  cout << ans << endl;
  return 0;
}
0