結果

問題 No.1330 Multiply or Divide
ユーザー 7LJ2DLim1Zz2ccD7LJ2DLim1Zz2ccD
提出日時 2021-01-08 22:04:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 691 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 165,908 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 03:08:03
合計ジャッジ時間 3,735 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int get_ceil(long long m,long long tmp){
  int ans=1;
  long long cur=tmp;
  while(cur<m){
    cur*=tmp;
    ans++;
  }
  return ans;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  long long m,p;
  cin>>n>>m>>p;
  long long tmp;
  long long min_a=-1;
  for(int i=0;i<n;i++){
    cin>>tmp;
    if (tmp>m){
      min_a=1;
    }else{
      long long cnt=0;
      while(tmp%p==0){
	cnt++;
	tmp/=p;
      }
      if (tmp==1) continue;
      int ttt=get_ceil(m,tmp);
      if(min_a==-1){
	min_a=ttt+cnt*(ttt-1);
      }else{
	min_a=min(min_a,ttt+cnt*(ttt-1));
      }
    }
    
  }
  cout<<min_a<<"\n";
  return 0;
}
0