結果

問題 No.1140 EXPotentiaLLL!
ユーザー 8989
提出日時 2022-02-06 03:20:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 586 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 119,360 KB
最終ジャッジ日時 2023-09-02 06:55:09
合計ジャッジ時間 8,283 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 549 ms
119,256 KB
testcase_01 AC 535 ms
118,664 KB
testcase_02 AC 511 ms
119,360 KB
testcase_03 AC 487 ms
118,320 KB
testcase_04 AC 465 ms
117,880 KB
testcase_05 AC 556 ms
118,696 KB
testcase_06 AC 545 ms
118,356 KB
testcase_07 AC 586 ms
119,264 KB
testcase_08 AC 248 ms
115,636 KB
testcase_09 AC 250 ms
115,308 KB
testcase_10 AC 250 ms
115,340 KB
testcase_11 AC 249 ms
115,200 KB
testcase_12 AC 246 ms
115,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import random
import math
def eratosthenes(n):
    a = [True] * n
    a[0] = False
    a[1] = False
    for i in range(2, math.ceil(math.sqrt(n - 1))):
        if not a[i]:
            continue
        for j in range(2, (n - 1) // i + 1):
            a[i * j] = False
    return a
n = 5000001
Q = eratosthenes(n)
from sys import stdin
#print(Q[0])
t = int(input())
for i in range(t):
  a,p = map(int,stdin.readline().rstrip().split())
  if Q[p]:
    if a % p == 0:
      print(0)
    else:
      print(1)
  else:
    print(-1)
0