結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 9 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 102 ms
12,332 KB
testcase_06 AC 51 ms
7,688 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 9 ms
4,380 KB
testcase_20 AC 29 ms
5,924 KB
testcase_21 AC 12 ms
4,380 KB
testcase_22 AC 10 ms
4,384 KB
testcase_23 AC 19 ms
6,436 KB
testcase_24 AC 28 ms
5,668 KB
testcase_25 AC 47 ms
8,240 KB
testcase_26 AC 49 ms
7,940 KB
testcase_27 AC 7 ms
4,380 KB
testcase_28 AC 20 ms
5,952 KB
testcase_29 AC 45 ms
8,004 KB
testcase_30 AC 8 ms
4,376 KB
testcase_31 AC 38 ms
6,680 KB
testcase_32 AC 47 ms
8,476 KB
testcase_33 AC 113 ms
14,084 KB
testcase_34 AC 111 ms
14,092 KB
testcase_35 AC 99 ms
11,512 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 = 1L * (N-1) * d;
        ans += max(0, L-x+1);
    }

    ans.writeln;
}
0