結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 31 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 76 ms
5,376 KB
testcase_19 AC 77 ms
5,376 KB
testcase_20 AC 79 ms
5,376 KB
testcase_21 AC 82 ms
5,376 KB
testcase_22 AC 81 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 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 WA -
testcase_34 AC 58 ms
5,376 KB
testcase_35 AC 17 ms
5,376 KB
testcase_36 AC 50 ms
5,376 KB
testcase_37 AC 47 ms
5,376 KB
testcase_38 AC 27 ms
5,376 KB
testcase_39 AC 20 ms
5,376 KB
testcase_40 AC 24 ms
5,376 KB
testcase_41 AC 14 ms
5,376 KB
testcase_42 AC 42 ms
5,376 KB
testcase_43 AC 49 ms
5,376 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
			}
		}
	}
	cout<<(ans==(int)1e9?-1:ans)<<endl;
}
0