結果

問題 No.1330 Multiply or Divide
ユーザー 👑 NachiaNachia
提出日時 2021-01-08 22:20:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 683 bytes
コンパイル時間 1,930 ms
コンパイル使用メモリ 199,752 KB
実行使用メモリ 6,860 KB
最終ジャッジ日時 2023-08-10 12:30:10
合計ジャッジ時間 4,559 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 29 ms
6,616 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 23 ms
6,624 KB
testcase_07 AC 90 ms
6,568 KB
testcase_08 AC 36 ms
6,580 KB
testcase_09 AC 39 ms
6,664 KB
testcase_10 AC 36 ms
6,704 KB
testcase_11 AC 35 ms
6,608 KB
testcase_12 AC 35 ms
6,720 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 32 ms
6,552 KB
testcase_19 AC 32 ms
6,532 KB
testcase_20 AC 32 ms
6,528 KB
testcase_21 AC 32 ms
6,524 KB
testcase_22 AC 33 ms
6,528 KB
testcase_23 AC 34 ms
6,860 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 24 ms
5,732 KB
testcase_35 AC 8 ms
4,380 KB
testcase_36 AC 22 ms
5,596 KB
testcase_37 AC 19 ms
5,320 KB
testcase_38 AC 13 ms
4,684 KB
testcase_39 AC 10 ms
4,472 KB
testcase_40 AC 11 ms
4,400 KB
testcase_41 AC 6 ms
4,376 KB
testcase_42 AC 18 ms
5,224 KB
testcase_43 AC 21 ms
5,396 KB
testcase_44 AC 24 ms
6,760 KB
testcase_45 AC 26 ms
6,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

ULL N,M,P;
ULL maxA,maxB;
pair<ULL,ULL> A[200000];

int main(){
	scanf("%llu%llu%llu",&N,&M,&P);
	maxA=1; maxB=1;
	rep(i,N){
		ULL a; scanf("%llu",&a);
		maxA=max(maxA,a);
		int p=1;
		while(a%P==0){ a/=P; p++; }
		A[i]={a,p};
		maxB=max(maxB,a);
	}
	ULL x=1;
	if(maxA>M){ printf("1\n"); return 0; }
	if(maxB==1){ printf("-1\n"); return 0; }
	ULL ans=1000000;
	M=(M-1)/maxA+1;
	rep(i,N){
		if(A[i].first==1) continue;
		ULL x=1, tmp=1;
		while(x<=M){ x*=A[i].first; tmp+=A[i].second; }
		ans=min(ans,tmp);
	}
	printf("%llu\n",ans);
	return 0;
}
0