結果

問題 No.1140 EXPotentiaLLL!
ユーザー c-yanc-yan
提出日時 2020-08-03 04:57:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 702 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 63,544 KB
最終ジャッジ日時 2023-09-29 13:15:25
合計ジャッジ時間 14,269 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 978 ms
63,544 KB
testcase_01 AC 948 ms
63,096 KB
testcase_02 AC 990 ms
63,472 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 433 ms
47,100 KB
testcase_09 AC 438 ms
47,020 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 428 ms
47,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_prime_table(n):
    sieve = [True] * (n + 1)
    sieve[0] = False
    sieve[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not sieve[i]:
            continue
        for j in range(i * i, n + 1, 2 * i):
            sieve[j] = False
    return sieve


def main():
    readline = open(0).readline

    prime_table = make_prime_table(5 * 10 ** 6)

    T = int(readline())
    result = []
    for _ in range(T):
        A, P = map(int, readline().split())
        if not prime_table[P]:
            result.append(-1)
        else:
            if A % P == 0:
                result.append(0)
            else:
                result.append(1)
    print(*result, sep='\n')


main()
0