結果

問題 No.1330 Multiply or Divide
ユーザー kotatsugamekotatsugame
提出日時 2021-01-08 21:31:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 445 bytes
コンパイル時間 448 ms
コンパイル使用メモリ 66,800 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 05:41:51
合計ジャッジ時間 3,500 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 61 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 33 ms
5,376 KB
testcase_07 AC 93 ms
5,376 KB
testcase_08 AC 79 ms
5,376 KB
testcase_09 AC 85 ms
5,376 KB
testcase_10 AC 81 ms
5,376 KB
testcase_11 AC 80 ms
5,376 KB
testcase_12 AC 79 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 75 ms
5,376 KB
testcase_19 AC 78 ms
5,376 KB
testcase_20 AC 77 ms
5,376 KB
testcase_21 AC 81 ms
5,376 KB
testcase_22 AC 80 ms
5,376 KB
testcase_23 AC 87 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 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 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 56 ms
5,376 KB
testcase_35 AC 17 ms
5,376 KB
testcase_36 AC 50 ms
5,376 KB
testcase_37 AC 46 ms
5,376 KB
testcase_38 AC 29 ms
5,376 KB
testcase_39 AC 20 ms
5,376 KB
testcase_40 AC 24 ms
5,376 KB
testcase_41 AC 13 ms
5,376 KB
testcase_42 AC 42 ms
5,376 KB
testcase_43 AC 49 ms
5,376 KB
testcase_44 AC 34 ms
5,376 KB
testcase_45 AC 36 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,M,P;
int A[2<<17];
main()
{
	cin>>N>>M>>P;
	int mM=M;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		mM=min(mM,M/A[i]);
	}
	if(mM==0)
	{
		cout<<1<<endl;
		return 0;
	}
	int ans=1e9;
	for(int i=0;i<N;i++)
	{
		int a=A[i],c=0;
		while(a%P==0)a/=P,c++;
		if(a==1)continue;
		int d=0;
		long t=1;
		while(t<=mM)t*=a,d++;
		ans=min(ans,d*(c+1)+1);
	}
	cout<<(ans==(int)1e9?-1:ans)<<endl;
}
0