結果

問題 No.1330 Multiply or Divide
ユーザー 7LJ2DLim1Zz2ccD
提出日時 2021-01-08 21:56:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 685 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 165,684 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-11-16 11:27:44
合計ジャッジ時間 57,561 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 9 TLE * 18
権限があれば一括ダウンロードができます

ソースコード

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