結果
| 問題 |
No.458 異なる素数の和
|
| ユーザー |
|
| 提出日時 | 2016-12-09 10:02:54 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 723 bytes |
| コンパイル時間 | 853 ms |
| コンパイル使用メモリ | 107,876 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 05:29:13 |
| 合計ジャッジ時間 | 3,944 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 26 WA * 2 |
ソースコード
import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;
import core.bitop;
void main() {
auto N = readln.chomp.to!int;
int M = 40000;
auto pt = new bool[](M);
foreach (i; 2..M)
pt[i] = true;
foreach (i; 2..M)
if (pt[i])
foreach (j; iota(i+i, M, i))
pt[j] = false;
int[] P;
foreach (i; 2..M)
if (pt[i])
P ~= i;
auto dp = new int[](100000);
foreach (p; P) {
foreach (i; iota(N, -1, -1))
if (dp[i] > 0) {
dp[p+i] = max(dp[p+i], dp[i]+1);
}
dp[p] = max(dp[p], 1);
}
dp[N].writeln;
}