結果
| 問題 |
No.1657 Sum is Prime (Easy Version)
|
| コンテスト | |
| ユーザー |
kokatsu
|
| 提出日時 | 2022-11-20 21:34:33 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| コード長 | 493 bytes |
| コンパイル時間 | 2,358 ms |
| コンパイル使用メモリ | 204,204 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-22 16:45:04 |
| 合計ジャッジ時間 | 2,871 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
import std;
void main() {
int L, R;
readf("%d %d\n", L, R);
int N = R * 2 + 10;
auto sieve = new bool[](N+1);
sieve[2..N+1] = true;
int d = 2;
while (d * d <= N) {
if (sieve[d]) {
foreach (i; iota(d*d, N+1, d)) {
sieve[i] = false;
}
}
++d;
}
int res;
foreach (i; L .. R) {
if (sieve[i]) ++res;
if (sieve[i*2+1]) ++res;
}
if (sieve[R]) ++res;
res.writeln;
}
kokatsu