結果

問題 No.1140 EXPotentiaLLL!
ユーザー 8989
提出日時 2022-02-06 03:17:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 583 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 119,200 KB
最終ジャッジ日時 2023-09-02 06:54:59
合計ジャッジ時間 8,337 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 537 ms
119,200 KB
testcase_01 AC 533 ms
118,376 KB
testcase_02 AC 534 ms
119,008 KB
testcase_03 AC 509 ms
118,160 KB
testcase_04 AC 462 ms
118,108 KB
testcase_05 AC 548 ms
118,328 KB
testcase_06 AC 536 ms
118,340 KB
testcase_07 AC 583 ms
119,136 KB
testcase_08 AC 262 ms
115,180 KB
testcase_09 AC 253 ms
115,272 KB
testcase_10 AC 256 ms
115,180 KB
testcase_11 AC 256 ms
115,000 KB
testcase_12 AC 253 ms
115,132 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