結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
![]() |
提出日時 | 2020-08-09 12:21:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 597 ms / 2,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 1,020 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 146,236 KB |
最終ジャッジ日時 | 2024-10-04 08:59:29 |
合計ジャッジ時間 | 8,689 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
import sys input = sys.stdin.readline def sieve(n): res = [True for _ in range(n + 1)] res[0] = False res[1] = False i = 2 while i * i <= n: if res[i]: for j in range(i * 2, n + 1, i): res[j] = False i += 1 return res T = int(input()) S = sieve(5 * 10**6) res = [] for _ in range(T): a, p = map(int, input().split()) if not S[p]: res.append(-1) else: if a % p == 0: res.append(0) else: res.append(1) print('\n'.join(map(str, res)))