結果

問題 No.1140 EXPotentiaLLL!
ユーザー butamanbutaman
提出日時 2020-12-14 15:42:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 619 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 81,292 KB
実行使用メモリ 116,184 KB
最終ジャッジ日時 2023-10-20 05:02:57
合計ジャッジ時間 8,477 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 564 ms
116,144 KB
testcase_01 AC 534 ms
115,696 KB
testcase_02 AC 537 ms
116,156 KB
testcase_03 AC 476 ms
115,524 KB
testcase_04 AC 463 ms
115,236 KB
testcase_05 AC 619 ms
115,696 KB
testcase_06 AC 494 ms
115,600 KB
testcase_07 AC 539 ms
116,184 KB
testcase_08 AC 312 ms
113,108 KB
testcase_09 AC 341 ms
113,192 KB
testcase_10 AC 317 ms
113,204 KB
testcase_11 AC 334 ms
113,260 KB
testcase_12 AC 315 ms
113,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys


def input():
   return sys.stdin.buffer.readline()[:-1]

MAXX = 5*10**6 + 5

isprime = [1]*MAXX
isprime[0] = isprime[1] = 0
#theratos
for num in range(2, MAXX):
    if isprime[num]:
        for k in range(num*2, MAXX, num):
            isprime[k] = 0

T = int(input())
for tt in range(T):
    A, P = map(int, input().split())
    if isprime[P]:
        if A % P == 0:
            print(0)
        else:
            #ferma
            print(1)
    else:
        print(-1)

0