結果

問題 No.1140 EXPotentiaLLL!
ユーザー 👑 KazunKazun
提出日時 2020-08-16 04:22:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,584 KB
実行使用メモリ 123,776 KB
最終ジャッジ日時 2024-04-19 18:15:05
合計ジャッジ時間 8,807 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 579 ms
122,112 KB
testcase_01 AC 572 ms
123,776 KB
testcase_02 WA -
testcase_03 AC 499 ms
121,472 KB
testcase_04 AC 443 ms
119,936 KB
testcase_05 AC 561 ms
123,520 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 187 ms
96,768 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 185 ms
96,896 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):
    _,P=map(int,input().split())
    if Prime_List[P]:
        X[k]=1
    else:
        X[k]=-1

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