結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-01-12 04:16:16 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 106 ms / 1,000 ms |
| コード長 | 701 bytes |
| コンパイル時間 | 663 ms |
| コンパイル使用メモリ | 116,916 KB |
| 実行使用メモリ | 13,188 KB |
| 最終ジャッジ日時 | 2024-06-12 23:30:17 |
| 合計ジャッジ時間 | 2,503 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 31 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;
immutable int INF = 1 << 28;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto L = s[1];
auto table = new bool[](L+1);
table.fill(true);
for (int i = 2; i <= L; ++i) {
if (!table[i]) continue;
for (int j = i+i; j <= L; j += i) {
table[j] = false;
}
}
long ans = 0;
foreach (d; 2..L+1) {
if (!table[d]) continue;
long x = 1L * (N-1) * d;
ans += max(0, L-x+1);
}
ans.writeln;
}