結果

問題 No.1140 EXPotentiaLLL!
ユーザー uni_pythonuni_python
提出日時 2020-08-03 20:47:19
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 810 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 86,856 KB
実行使用メモリ 117,708 KB
最終ジャッジ日時 2023-10-11 17:04:07
合計ジャッジ時間 10,261 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 600 ms
117,472 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 408 ms
115,112 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    T=I()
    #nまでの素数を列挙(n loglogn)
    n = 5*(10**6)+10

    #is_prime[i]にはi-1が素数か否かを示すboolが入る,[0]に1の素数判定がある.
    is_prime = [True]*(n+1)
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i

    import math
    for i in range(T):
        A,P=MI()
        if is_prime[P+1]==1:
            if math.gcd(A,P)==1:
                print(1)
            else:
                print(0)
        else:
            print(-1)


main()
0