結果

問題 No.1140 EXPotentiaLLL!
ユーザー eSeFeSeF
提出日時 2020-07-26 21:23:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 612 bytes
コンパイル時間 1,026 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 47,732 KB
最終ジャッジ日時 2023-09-11 05:06:16
合計ジャッジ時間 31,959 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,692 ms
47,016 KB
testcase_09 AC 1,668 ms
46,944 KB
testcase_10 AC 1,692 ms
46,976 KB
testcase_11 AC 1,685 ms
47,000 KB
testcase_12 AC 1,711 ms
46,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
def main():
    MX_T=500000
    MX_P=5000000
    MX_A=1000000000000000000
    isprime=[True]*(MX_P+1)
    isprime[0]=isprime[1]=False
    for n in range(2,MX_P+1):
        if isprime[n]:
            s=2*n
            while s<=MX_P:
                isprime[s]=False
                s+=n
    T=int(input())
    assert(1<=T<=MX_T)
    for _ in range(T):
        A,P=map(int,input().split())
        assert(1<=A<=MX_A)
        assert(1<=P<=MX_P)
        if isprime[P]:
            print(0 if A%P==0 else 1)
        else:
            print(-1)
if __name__=='__main__':
    main()
0