結果

問題 No.1140 EXPotentiaLLL!
ユーザー butamanbutaman
提出日時 2020-12-14 14:36:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 331 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 81,736 KB
実行使用メモリ 115,376 KB
最終ジャッジ日時 2023-10-20 05:00:54
合計ジャッジ時間 16,598 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import math

MAXX = 5*10**6 + 5

isprime = [1]*(MAXX)
#theratos
for num in range(2, MAXX):
    if isprime[num]:
        for k in range(num*2, MAXX, num):
            isprime[k] = 0

T = int(input())
for tt in range(T):
    A, P = map(int, input().split())
    if isprime[P]:
        print(P - (A % P))
    else:
        print(-1)

0