結果

問題 No.1140 EXPotentiaLLL!
ユーザー toyuzukotoyuzuko
提出日時 2020-08-09 12:20:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 506 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 52,016 KB
最終ジャッジ日時 2024-04-15 01:31:32
合計ジャッジ時間 27,288 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 AC 1,844 ms
50,032 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,138 ms
49,756 KB
testcase_09 AC 1,164 ms
49,736 KB
testcase_10 AC 1,150 ms
49,816 KB
testcase_11 AC 1,208 ms
49,744 KB
testcase_12 AC 1,211 ms
49,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def sieve(n):
    res = [True for _ in range(n + 1)]
    res[0] = False
    res[1] = False
    i = 2
    while i * i <= n:
        if res[i]:
            for j in range(i * 2, n + 1, i):
                res[j] = False
        i += 1
    return res

T = int(input())
S = sieve(5 * 10**6)

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