結果

問題 No.1140 EXPotentiaLLL!
ユーザー O2MTO2MT
提出日時 2020-12-06 14:00:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,546 ms / 2,000 ms
コード長 492 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 81,296 KB
実行使用メモリ 182,944 KB
最終ジャッジ日時 2023-10-17 15:20:22
合計ジャッジ時間 17,100 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,491 ms
182,820 KB
testcase_01 AC 1,454 ms
182,640 KB
testcase_02 AC 1,451 ms
182,820 KB
testcase_03 AC 1,270 ms
182,876 KB
testcase_04 AC 1,061 ms
182,944 KB
testcase_05 AC 1,476 ms
182,748 KB
testcase_06 AC 1,414 ms
182,944 KB
testcase_07 AC 1,546 ms
182,704 KB
testcase_08 AC 292 ms
181,748 KB
testcase_09 AC 292 ms
181,752 KB
testcase_10 AC 296 ms
181,748 KB
testcase_11 AC 297 ms
181,752 KB
testcase_12 AC 309 ms
181,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def eratosthenes_sieve(n):
    table = [0] * (n+1)
    prime_list = []
    for i in range(2, n+1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i+i, n+1, i):
                table[j] = 1
    return prime_list

N = 5*(10**6)+1
E = set(eratosthenes_sieve(N))
T = int(input())
for _ in range(T):
    A,P = map(int,input().split())
    if P not in E:
        print(-1)
    else:
        if A%P != 0:
            print(1)
        else:
            print(0)
0