結果

問題 No.1140 EXPotentiaLLL!
ユーザー qumazakiqumazaki
提出日時 2020-09-08 17:37:26
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 872 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 86,248 KB
実行使用メモリ 297,964 KB
最終ジャッジ日時 2023-08-20 02:00:28
合計ジャッジ時間 10,050 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 750 ms
259,836 KB
testcase_01 RE -
testcase_02 AC 520 ms
261,252 KB
testcase_03 AC 457 ms
249,716 KB
testcase_04 AC 439 ms
265,248 KB
testcase_05 AC 546 ms
261,660 KB
testcase_06 AC 507 ms
258,256 KB
testcase_07 AC 619 ms
297,964 KB
testcase_08 AC 272 ms
163,208 KB
testcase_09 AC 218 ms
163,192 KB
testcase_10 AC 219 ms
163,272 KB
testcase_11 AC 226 ms
163,200 KB
testcase_12 AC 224 ms
163,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def sieve(n):
    if( n <= 1):
        return []
    elif(n==2):
        return [2]

    primes = [2]
    len_list = (n+1)//2
    len_sqrt = int(len_list**0.5) + 1
    flags = [True] * len_list
    flags[0] = False
    for i in range(len_sqrt):
        if(flags[i]):
            start = ((i*2+1)**2)//2
            for j in range( start, len_list, i*2+1):
                flags[j] = False
    return [2] + [i*2+1 for i in range(len_list) if flags[i]]

t = int(readline())
data = list(map(int,read().split()))

primes = sieve(5*10**6)
nums = [-1]*(5*10**6)
for pi in primes:
    nums[pi]=1

ans = []
it = iter(data)
for a,p in zip(it,it):
    if(nums[p]==-1):
        ans.append(-1)
    else:
        ans.append(1*(a%p > 0))

print('\n'.join(map(str,ans)))
0