結果

問題 No.1140 EXPotentiaLLL!
ユーザー 👑 KazunKazun
提出日時 2020-08-16 04:23:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 583 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 123,800 KB
最終ジャッジ日時 2024-04-19 18:15:17
合計ジャッジ時間 7,793 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 563 ms
122,316 KB
testcase_01 AC 567 ms
123,800 KB
testcase_02 AC 547 ms
122,120 KB
testcase_03 AC 516 ms
121,932 KB
testcase_04 AC 443 ms
120,320 KB
testcase_05 AC 553 ms
123,456 KB
testcase_06 AC 540 ms
123,392 KB
testcase_07 AC 583 ms
122,496 KB
testcase_08 AC 181 ms
97,296 KB
testcase_09 AC 175 ms
97,152 KB
testcase_10 AC 183 ms
97,792 KB
testcase_11 AC 176 ms
97,152 KB
testcase_12 AC 177 ms
97,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Sieve_of_Eratosthenes(N,mode=False):
    """Nまでのエラトステネスの篩を実行

    N:自然数
    mode:False->素数のリスト,True->素数かどうかのリスト
    (False->[2,3,5,...],True->[False,False,True,True,False,True,...])
    """

    T=[True]*(N+1)
    T[0]=T[1]=0
    a=2
    while a*a<=N:
        if T[a]:
            b=a*a
            while b<=N:
                T[b]=False
                b+=a
        a+=1

    if mode:
        return T
    else:
        return [k for k in range(N+1) if T[k]]
#===========================================================
P_max=5*10**6
Prime_List=Sieve_of_Eratosthenes(P_max,True)

T=int(input())
X=[0]*T
for k in range(T):
    A,P=map(int,input().split())
    if Prime_List[P]:
        if A%P:
            X[k]=1
        else:
            X[k]=0
    else:
        X[k]=-1

print("\n".join(map(str,X)))
0