結果

問題 No.1330 Multiply or Divide
ユーザー kotatsugamekotatsugame
提出日時 2021-01-09 02:26:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 598 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 67,144 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 08:22:37
合計ジャッジ時間 3,401 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 65 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 32 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 83 ms
6,944 KB
testcase_09 AC 81 ms
6,940 KB
testcase_10 AC 78 ms
6,944 KB
testcase_11 AC 79 ms
6,944 KB
testcase_12 AC 82 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 79 ms
6,940 KB
testcase_19 AC 77 ms
6,940 KB
testcase_20 AC 78 ms
6,940 KB
testcase_21 AC 78 ms
6,940 KB
testcase_22 AC 78 ms
6,940 KB
testcase_23 AC 81 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 1 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 1 ms
6,944 KB
testcase_32 AC 1 ms
6,944 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 54 ms
6,944 KB
testcase_35 AC 17 ms
6,940 KB
testcase_36 AC 54 ms
6,940 KB
testcase_37 AC 48 ms
6,940 KB
testcase_38 AC 30 ms
6,940 KB
testcase_39 AC 20 ms
6,940 KB
testcase_40 AC 24 ms
6,940 KB
testcase_41 AC 12 ms
6,940 KB
testcase_42 AC 44 ms
6,944 KB
testcase_43 AC 48 ms
6,944 KB
testcase_44 AC 32 ms
6,944 KB
testcase_45 AC 32 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,M,P;
int A[2<<17];
long dp[100];
int B[32];
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;
	}
	dp[0]=1;
	for(int i=0;i<N;i++)
	{
		int a=A[i],c=1;
		while(a%P==0)a/=P,c++;
		B[c]=max(B[c],a);
	}
	int ans=1e9;
	for(int i=0;i<100;i++)if(dp[i]>0&&dp[i]<=mM)
	{
		for(int j=1;j<32&&i+j<100;j++)
		{
			if(dp[i+j]<dp[i]*B[j])
			{
				dp[i+j]=dp[i]*B[j];
				if(dp[i+j]>mM)ans=min(ans,i+j+1);
			}
		}
	}
	cout<<(ans==(int)1e9?-1:ans)<<endl;
}
0