結果
| 問題 |
No.458 異なる素数の和
|
| コンテスト | |
| ユーザー |
紙ぺーぱー
|
| 提出日時 | 2016-12-08 02:37:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 684 ms / 2,000 ms |
| コード長 | 401 bytes |
| コンパイル時間 | 1,453 ms |
| コンパイル使用メモリ | 165,984 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-05 05:31:07 |
| 合計ジャッジ時間 | 22,020 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int n,dp[20050];
int main(){
scanf("%d\n",&n);
assert(1<=n&&n<=20000);
for(int i=1;i<20050;i++)dp[i]=-1000000000;
for(int i=2;i<20050;i++){
int ok=1;
for(int j=2;j<i;j++)if(i%j==0)ok=0;
if(ok)for(int j=20050-1;j>=i;j--)dp[j]=max(dp[j],dp[j-i]+1);
}
if(dp[n]<0)cout<<-1<<endl;
else cout<<dp[n]<<endl;
}
紙ぺーぱー