結果

問題 No.1140 EXPotentiaLLL!
ユーザー renand_narirenand_nari
提出日時 2020-07-31 22:01:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 904 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 147,332 KB
最終ジャッジ日時 2023-09-20 23:18:46
合計ジャッジ時間 12,388 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 904 ms
146,628 KB
testcase_01 AC 895 ms
146,308 KB
testcase_02 AC 871 ms
147,332 KB
testcase_03 AC 808 ms
138,536 KB
testcase_04 AC 752 ms
132,076 KB
testcase_05 AC 881 ms
146,120 KB
testcase_06 AC 843 ms
142,332 KB
testcase_07 AC 889 ms
145,632 KB
testcase_08 AC 496 ms
116,180 KB
testcase_09 AC 485 ms
116,452 KB
testcase_10 AC 482 ms
116,608 KB
testcase_11 AC 490 ms
116,312 KB
testcase_12 AC 485 ms
116,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
def prime_table():
    don = [1 for i in range(5*(10**6)+1)]
    don[0]=0
    don[1]=0
    for i in range(2,5*(10**6)+1):
        if(don[i]):
            for j in range(i+i,5*(10**6)+1,i):
                don[j] = 0
    return don

hurui = prime_table()
t = int(input())
res = []
for i in range(t):
    a,p=map(int, input().split())
    if(not hurui[p]):
        res.append(-1)
    else:
        if(a%p==0):
            res.append(0)
        else:
            res.append(1)
for i in res:
    print(i)
0