結果

問題 No.1140 EXPotentiaLLL!
ユーザー FromBooskaFromBooska
提出日時 2023-02-23 21:07:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,474 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 1,286 ms
コンパイル使用メモリ 86,604 KB
実行使用メモリ 116,932 KB
最終ジャッジ日時 2023-09-30 21:03:11
合計ジャッジ時間 15,902 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,409 ms
116,216 KB
testcase_01 AC 1,448 ms
116,296 KB
testcase_02 AC 1,422 ms
116,340 KB
testcase_03 AC 1,244 ms
116,488 KB
testcase_04 AC 1,009 ms
116,568 KB
testcase_05 AC 1,411 ms
116,492 KB
testcase_06 AC 1,370 ms
116,412 KB
testcase_07 AC 1,474 ms
116,932 KB
testcase_08 AC 295 ms
115,524 KB
testcase_09 AC 294 ms
115,560 KB
testcase_10 AC 308 ms
115,660 KB
testcase_11 AC 297 ms
115,772 KB
testcase_12 AC 290 ms
115,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = 5*10**6+2
is_prime = [1]*(n + 1)
is_prime[0] = 0  
is_prime[1] = 0
for p in range(2, n + 1):
    if is_prime[p]:
        for q in range(2*p, n + 1, p):
            is_prime[q] = 0
        
T = int(input())
for t in range(T):
    A, P = map(int, input().split())
    if is_prime[P] == 0:
        print(-1)
    else:
        if A%P == 0:
            print(0)
        else:
            print(1)
0