結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー nebukuro09nebukuro09
提出日時 2018-01-12 04:15:33
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 696 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 101,484 KB
実行使用メモリ 13,052 KB
最終ジャッジ日時 2023-09-03 18:05:08
合計ジャッジ時間 2,882 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 8 ms
4,832 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 9 ms
4,820 KB
testcase_20 AC 26 ms
5,656 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 47 ms
7,856 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 47 ms
7,436 KB
testcase_33 AC 107 ms
12,796 KB
testcase_34 AC 106 ms
13,052 KB
testcase_35 AC 92 ms
11,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = (N-1) * d;
        ans += max(0, L-x+1);
    }

    ans.writeln;
}
0