結果

問題 No.1058 素敵な数
ユーザー kokatsukokatsu
提出日時 2021-10-13 21:45:37
言語 D
(dmd 2.107.1)
結果
WA  
実行時間 -
コード長 533 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 204,876 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-04 14:27:44
合計ジャッジ時間 3,304 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    int N;
    readf("%d\n", N);

    int limit = 10 ^^ 5;
    int size = limit * 2;
    int ssqrt = size.to!real.sqrt.floor.to!int;
    auto sieve = iota(0, size).map!(i => i == 2 || (i > 2 && i % 2 == 1)).array;
    foreach (i; iota(3, ssqrt, 2)) {
        if (!sieve[i]) {
            continue;
        }
        foreach (j; iota(i*i, size, i)) {
            sieve[j] = false;
        }
    }

    auto nice = iota(0, size).filter!(i => i == 1 || (i > limit && sieve[i])).array;
    nice[N-1].writeln;
}
0