結果

問題 No.1140 EXPotentiaLLL!
ユーザー convexineqconvexineq
提出日時 2021-05-10 06:49:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,502 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 81,452 KB
実行使用メモリ 208,460 KB
最終ジャッジ日時 2023-10-19 15:06:07
合計ジャッジ時間 19,899 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,484 ms
208,452 KB
testcase_01 AC 1,473 ms
208,456 KB
testcase_02 AC 1,472 ms
208,452 KB
testcase_03 AC 1,276 ms
208,452 KB
testcase_04 AC 1,106 ms
208,332 KB
testcase_05 AC 1,485 ms
208,456 KB
testcase_06 AC 1,389 ms
208,460 KB
testcase_07 AC 1,502 ms
208,360 KB
testcase_08 AC 313 ms
200,880 KB
testcase_09 AC 329 ms
200,912 KB
testcase_10 AC 323 ms
200,948 KB
testcase_11 AC 324 ms
201,036 KB
testcase_12 AC 326 ms
200,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Eratosthenes(N): #N以下の素数のリストを返す
    N+=1
    is_prime_list = [True]*N
    m = int(N**0.5)+1
    for i in range(3,m,2):
        if is_prime_list[i]:
            is_prime_list[i*i::2*i]=[False]*((N-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,N,2) if is_prime_list[i]]

N = 5*10**6
ok = [0]*(N+1)
for i in Eratosthenes(N):
    ok[i] = 1

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