結果
問題 | No.577 Prime Powerful Numbers |
ユーザー | 👑 rin204 |
提出日時 | 2022-10-02 14:58:21 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,224 bytes |
コンパイル時間 | 437 ms |
コンパイル使用メモリ | 87,232 KB |
実行使用メモリ | 78,040 KB |
最終ジャッジ日時 | 2023-08-26 09:19:21 |
合計ジャッジ時間 | 2,854 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 86 ms
76,764 KB |
testcase_01 | AC | 108 ms
77,468 KB |
testcase_02 | WA | - |
testcase_03 | AC | 148 ms
77,924 KB |
testcase_04 | AC | 94 ms
76,820 KB |
testcase_05 | AC | 320 ms
77,744 KB |
testcase_06 | AC | 116 ms
77,328 KB |
testcase_07 | AC | 327 ms
77,952 KB |
testcase_08 | AC | 142 ms
78,040 KB |
testcase_09 | AC | 144 ms
77,832 KB |
testcase_10 | AC | 74 ms
71,692 KB |
ソースコード
def isprime(n): if n <= 1: return False elif n == 2: return True elif n % 2 == 0: return False A = [2, 325, 9375, 28178, 450775, 9780504, 1795265022] s = 0 d = n - 1 while d % 2 == 0: s += 1 d >>= 1 for a in A: if a % n == 0: return True x = pow(a, d, n) if x != 1: for t in range(s): if x == n - 1: break x = x * x % n else: return False return True def invc(x, c): i = int(x ** (1 / c)) while i ** c < x: i += 1 while i ** c > x: i -= 1 return i def ok(x): if isprime(x): return True c = 2 while 1: i = invc(x, c) if i ** c == x: return True if i <= 2: break c += 1 return False def solve(x): if x == 2: print("No") return if not x & 1: print("Yes") return b = 2 while b < x: if ok(x - b): print("Yes") return b *= 2 print("No") for _ in range(int(input())): solve(int(input()))