結果

問題 No.1140 EXPotentiaLLL!
ユーザー butamanbutaman
提出日時 2020-12-14 15:38:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 460 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 81,804 KB
実行使用メモリ 115,796 KB
最終ジャッジ日時 2023-10-20 05:02:15
合計ジャッジ時間 8,361 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import math
import sys


def input():
   return sys.stdin.buffer.readline()[:-1]

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]:
        if A % P == 0:
            print(0)
        else:
            print(P - (A % P))
    else:
        print(-1)

0