結果

問題 No.1330 Multiply or Divide
ユーザー 7LJ2DLim1Zz2ccD
提出日時 2021-01-08 22:13:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 788 bytes
コンパイル時間 1,633 ms
コンパイル使用メモリ 165,840 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-16 12:40:07
合計ジャッジ時間 3,800 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 39 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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)+1;
      }else{
	min_a=min(min_a,ttt+cnt*(ttt-1)+1);
      }
    }
    
  }
  cout<<min_a<<"\n";
  return 0;
}
0