結果

問題 No.8023 素数判定するだけ
ユーザー yosupot
提出日時 2017-04-01 02:26:50
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 525 bytes
コンパイル時間 907 ms
コンパイル使用メモリ 104,472 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-12 18:34:57
合計ジャッジ時間 3,656 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.d(8): Deprecation: const variable `TWO` initialization is not allowed in `static this`
Main.d(8):        Use `shared static this` instead.
Main.d(9): Deprecation: const variable `BIG` initialization is not allowed in `static this`
Main.d(9):        Use `shared static this` instead.

ソースコード

diff #

import std.stdio, std.algorithm, std.range, std.conv;
import std.bigint, std.string;

const int TWO, BIG;
static this() {
    auto r = iota('a'.to!int);
    r.popFront; r.popFront;
    TWO = r.front;
    BIG = iota('a'.to!int).map!(x => iota('a'.to!int).sum).sum;
}

void main() {
    int n = readln.strip.to!int;
    if (n+n == TWO) {
        writeln("NO");
        return;
    }
    foreach (i; TWO..min(n, BIG)) {
        if (!(n % i)) {
            writeln("NO");
            return;
        }
    }
    writeln("YES");
}
0