結果

問題 No.1330 Multiply or Divide
ユーザー 7LJ2DLim1Zz2ccD
提出日時 2021-01-08 22:15:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 780 bytes
コンパイル時間 1,319 ms
コンパイル使用メモリ 165,856 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-16 18:24:28
合計ジャッジ時間 3,272 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 45 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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