結果

問題 No.1140 EXPotentiaLLL!
ユーザー kokatsukokatsu
提出日時 2022-01-06 21:14:58
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 640 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 3,558 ms
コンパイル使用メモリ 206,432 KB
実行使用メモリ 9,696 KB
最終ジャッジ日時 2023-09-04 15:38:59
合計ジャッジ時間 13,168 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 640 ms
8,280 KB
testcase_01 AC 637 ms
8,412 KB
testcase_02 AC 635 ms
8,980 KB
testcase_03 AC 487 ms
8,424 KB
testcase_04 AC 392 ms
9,252 KB
testcase_05 AC 571 ms
8,960 KB
testcase_06 AC 547 ms
8,180 KB
testcase_07 AC 635 ms
9,020 KB
testcase_08 AC 83 ms
8,184 KB
testcase_09 AC 86 ms
8,464 KB
testcase_10 AC 84 ms
8,460 KB
testcase_11 AC 85 ms
8,652 KB
testcase_12 AC 84 ms
9,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

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

    long M = 5 * 10 ^^ 6;
    long S = M.to!real.sqrt.floor.to!long;
    auto sieve = iota(0L, M+1).map!(i => i == 2 || (i > 2 && i % 2 == 1)).array;
    foreach (i; iota(3, S+1, 2)) {
        if (!sieve[i]) {
            continue;
        }

        foreach (j; iota(i*i, M+1, i)) {
            sieve[j] = false;
        }
    }

    foreach (_; 0 .. T) {
        long A, P;
        readf("%d %d\n", A, P);

        long res = -1;
        if (sieve[P]) res = (A % P == 0 ? 0 : 1);

        res.writeln;
    }
}
0