結果

問題 No.1330 Multiply or Divide
ユーザー 7LJ2DLim1Zz2ccD7LJ2DLim1Zz2ccD
提出日時 2021-01-08 21:43:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 617 bytes
コンパイル時間 1,266 ms
コンパイル使用メモリ 166,252 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 02:35:36
合計ジャッジ時間 3,219 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
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;
      if(min_a==-1){
	min_a=ceil(log(m)/log(tmp))+cnt*(ceil(log(m)/log(tmp))-1);
      }else{
	min_a=min(min_a,(long long)ceil(log(m)/log(tmp))+cnt*((long long)ceil(log(m)/log(tmp))-1));
      }
    }
    
  }
  cout<<min_a<<"\n";
  return 0;
}
0