結果
問題 | No.1747 Many Formulae 2 |
ユーザー |
👑 |
提出日時 | 2021-12-13 01:32:57 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 823 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 82,420 KB |
実行使用メモリ | 68,796 KB |
最終ジャッジ日時 | 2024-07-21 15:10:05 |
合計ジャッジ時間 | 1,847 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 6 |
ソースコード
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 S = input() se = set() l = len(S) - 1 for bit in range(1 << l): eq = [] for i, s in enumerate(S): eq.append(s) if bit >> i & 1: eq.append("+") se.add(eval("".join(eq))) print(sum(isprime(n) for n in se))