結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー | Mine |
提出日時 | 2021-01-28 18:05:04 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 973 bytes |
コンパイル時間 | 597 ms |
コンパイル使用メモリ | 86,844 KB |
実行使用メモリ | 83,332 KB |
最終ジャッジ日時 | 2023-09-08 09:16:09 |
合計ジャッジ時間 | 4,483 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | AC | 117 ms
81,068 KB |
testcase_09 | AC | 116 ms
80,860 KB |
testcase_10 | AC | 116 ms
81,064 KB |
testcase_11 | AC | 115 ms
81,180 KB |
testcase_12 | AC | 118 ms
80,928 KB |
ソースコード
from collections import defaultdict import math def Sieve_of_Eratosthenes(maxA): lst = [-1]*(maxA+1) lst[0] = 0 lst[1] = 1 for i in range(2, maxA+1): if lst[i] == -1: for g in range(i, maxA+1, i): if lst[g] == -1: lst[g] = i return lst def is_prime(n): d = defaultdict(int) now = n while True: if now == lst[now]: if now != 1: d[now] += 1 break r = lst[now] while now % r == 0: now //= r d[r] += 1 if d[r] > 1 or len(d) > 1: return False if len(d) == 1: return True else: return False maxA = 5*10**5+1 lst = Sieve_of_Eratosthenes(maxA) t = int(input()) for _ in range(t): a, p = map(int, input().split()) if is_prime(p): if math.gcd(a, p) == 1: print(1) else: print(0) else: print(-1)