結果

問題 No.1140 EXPotentiaLLL!
ユーザー convexineqconvexineq
提出日時 2021-05-10 06:51:06
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 695 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 208,560 KB
最終ジャッジ日時 2023-10-19 15:08:02
合計ジャッジ時間 9,361 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 695 ms
208,560 KB
testcase_01 AC 539 ms
208,504 KB
testcase_02 AC 518 ms
208,556 KB
testcase_03 AC 490 ms
208,500 KB
testcase_04 AC 448 ms
208,504 KB
testcase_05 AC 531 ms
208,504 KB
testcase_06 AC 518 ms
208,508 KB
testcase_07 AC 573 ms
208,560 KB
testcase_08 AC 288 ms
200,896 KB
testcase_09 AC 284 ms
200,916 KB
testcase_10 AC 284 ms
200,928 KB
testcase_11 AC 282 ms
200,980 KB
testcase_12 AC 281 ms
200,900 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

import sys

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