結果

問題 No.1330 Multiply or Divide
ユーザー 7LJ2DLim1Zz2ccD7LJ2DLim1Zz2ccD
提出日時 2021-01-08 21:56:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 685 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 166,088 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-28 02:49:25
合計ジャッジ時間 5,591 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 25 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 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int get_ceil(long long m,long long tmp){
  int ans=1;
  int 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