結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 64 ms
6,940 KB
testcase_02 WA -
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 31 ms
6,944 KB
testcase_07 AC 100 ms
6,940 KB
testcase_08 AC 79 ms
6,944 KB
testcase_09 AC 88 ms
6,940 KB
testcase_10 AC 78 ms
6,940 KB
testcase_11 AC 81 ms
6,944 KB
testcase_12 AC 85 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 92 ms
6,940 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
6,944 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
6,944 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 34 ms
6,944 KB
testcase_45 AC 36 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;
  vector<pair<int, int>> ab;
  rep(i, n){
    int in;
    cin >> in;
    now = max((int)now, in);
    auto [a, b] = fc(in, p);
    if(a != 1){
      ab.push_back({a, b});
    }
  }
  int ans = 1001001001;
  if(now <= m){
    for(auto [a, b] : ab){
      ll nw = now;
      int add = 1;
      while(nw <= m){
        nw *= a;
        add += b;
      }
      ans = min(ans, add);
    }
  }
  if(ab.size() == 0) ans = -1;
  cout << ans << endl;
  return 0;
}
0