結果

問題 No.458 異なる素数の和
ユーザー kotatsugamekotatsugame
提出日時 2016-12-18 01:34:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 1,196 ms
コンパイル使用メモリ 96,292 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-08 06:06:40
合計ジャッジ時間 2,430 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 11 ms
5,248 KB
testcase_02 AC 13 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 25 ms
5,376 KB
testcase_06 AC 11 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 24 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 29 ms
5,376 KB
testcase_12 WA -
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 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 11 ms
5,376 KB
testcase_28 AC 28 ms
5,376 KB
testcase_29 WA -
testcase_30 AC 8 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<cstring>
using namespace std;
typedef long long int ll;
vector<int> p;
void makeprimelist(int n)
{
	bool *isp=new bool[++n];
	for(int i=0;i<n;i++)isp[i]=true;
	for(int i=2;i<n;i++)
	{
		if(isp[i])
		{
			p.push_back(i);
			for(int j=i;j<n;j+=i)isp[j]=false;
		}
	}
	return;
}
int main()
{
	int n;cin>>n;
	makeprimelist(20010);
	int dp[20100]={};
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	for(int j=0;j<p.size();j++)
	{
		for(int i=n;i>=p[j];i--)
		{
			dp[i]=max(dp[i],dp[i-p[j]]+1);
		}
	}
	cout<<(dp[n]?dp[n]:-1)<<endl;
	return 0;
}
0