結果

問題 No.1330 Multiply or Divide
ユーザー 7LJ2DLim1Zz2ccD7LJ2DLim1Zz2ccD
提出日時 2021-01-08 22:15:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 780 bytes
コンパイル時間 1,529 ms
コンパイル使用メモリ 167,832 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 05:45:53
合計ジャッジ時間 3,218 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 23 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 15 ms
6,940 KB
testcase_07 AC 85 ms
6,944 KB
testcase_08 AC 27 ms
6,940 KB
testcase_09 AC 30 ms
6,940 KB
testcase_10 AC 28 ms
6,940 KB
testcase_11 AC 26 ms
6,944 KB
testcase_12 AC 27 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 21 ms
6,940 KB
testcase_19 AC 23 ms
6,944 KB
testcase_20 AC 21 ms
6,940 KB
testcase_21 AC 24 ms
6,944 KB
testcase_22 AC 22 ms
6,940 KB
testcase_23 AC 26 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 1 ms
6,940 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 1 ms
6,940 KB
testcase_33 AC 1 ms
6,940 KB
testcase_34 AC 18 ms
6,944 KB
testcase_35 AC 7 ms
6,940 KB
testcase_36 AC 16 ms
6,944 KB
testcase_37 AC 15 ms
6,940 KB
testcase_38 AC 9 ms
6,940 KB
testcase_39 AC 6 ms
6,944 KB
testcase_40 AC 9 ms
6,944 KB
testcase_41 AC 4 ms
6,940 KB
testcase_42 AC 13 ms
6,940 KB
testcase_43 AC 15 ms
6,940 KB
testcase_44 AC 20 ms
6,940 KB
testcase_45 AC 21 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

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;
    long long tmp2=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;
      if(m%tmp2==0) ttt=get_ceil(m/tmp2,tmp);
      else ttt=get_ceil(m/tmp2+1,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