結果

問題 No.1140 EXPotentiaLLL!
ユーザー 👑 tamatotamato
提出日時 2020-07-31 21:32:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 501 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 87,504 KB
実行使用メモリ 117,860 KB
最終ジャッジ日時 2023-09-20 21:51:02
合計ジャッジ時間 7,502 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 447 ms
117,448 KB
testcase_01 AC 476 ms
117,124 KB
testcase_02 AC 458 ms
117,708 KB
testcase_03 AC 442 ms
117,860 KB
testcase_04 AC 402 ms
117,572 KB
testcase_05 AC 468 ms
117,732 KB
testcase_06 AC 453 ms
117,332 KB
testcase_07 AC 501 ms
117,472 KB
testcase_08 AC 270 ms
116,104 KB
testcase_09 AC 270 ms
116,048 KB
testcase_10 AC 279 ms
115,884 KB
testcase_11 AC 296 ms
116,016 KB
testcase_12 AC 258 ms
115,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    N0 = 5*10**6
    is_prime = [1] * (N0+1)
    is_prime[0] = is_prime[1] = 0
    for i in range(2, N0+1):
        if is_prime[i] == 0:
            continue
        for j in range(2, N0+1):
            if i*j > N0:
                break
            is_prime[i*j] = 0

    for _ in range(int(input())):
        a, p = map(int, input().split())
        if is_prime[p]:
            if a%p:
                print(1)
            else:
                print(0)
        else:
            print(-1)


if __name__ == '__main__':
    main()
0