結果
問題 | No.36 素数が嫌い! |
ユーザー | 👑 rin204 |
提出日時 | 2022-01-20 21:16:12 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,611 bytes |
コンパイル時間 | 173 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 63,488 KB |
最終ジャッジ日時 | 2024-11-24 05:59:10 |
合計ジャッジ時間 | 2,452 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
52,736 KB |
testcase_01 | AC | 45 ms
53,376 KB |
testcase_02 | AC | 43 ms
52,352 KB |
testcase_03 | WA | - |
testcase_04 | AC | 43 ms
52,736 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 43 ms
52,480 KB |
testcase_08 | AC | 43 ms
52,608 KB |
testcase_09 | AC | 46 ms
52,608 KB |
testcase_10 | AC | 42 ms
52,608 KB |
testcase_11 | AC | 43 ms
52,096 KB |
testcase_12 | AC | 43 ms
52,608 KB |
testcase_13 | AC | 57 ms
63,488 KB |
testcase_14 | AC | 47 ms
58,112 KB |
testcase_15 | AC | 43 ms
52,352 KB |
testcase_16 | AC | 43 ms
52,736 KB |
testcase_17 | AC | 42 ms
52,224 KB |
testcase_18 | AC | 42 ms
52,480 KB |
testcase_19 | AC | 43 ms
52,352 KB |
testcase_20 | AC | 44 ms
53,120 KB |
testcase_21 | AC | 42 ms
52,096 KB |
testcase_22 | AC | 42 ms
52,480 KB |
testcase_23 | AC | 44 ms
52,480 KB |
testcase_24 | AC | 48 ms
58,752 KB |
testcase_25 | AC | 43 ms
52,480 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
ソースコード
from math import gcd 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 pollard(n): if n % 2 == 0: return 2 if isprime(n): return n f = lambda x:(x * x + 1) % n step = 0 while 1: step += 1 x = step y = f(x) while 1: p = gcd(y - x + n, n) if p == 0 or p == n: break if p != 1: return p x = f(x) y = f(f(y)) def primefact(n): if n == 1: return [] p = pollard(n) if p == n: return [p] left = primefact(p) right = primefact(n // p) left += right return sorted(left) from math import gcd 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 pollard(n): if n % 2 == 0: return 2 if isprime(n): return n f = lambda x:(x * x + 1) % n step = 0 while 1: step += 1 x = step y = f(x) while 1: p = gcd(y - x + n, n) if p == 0 or p == n: break if p != 1: return p x = f(x) y = f(f(y)) def primefact(n): if n == 1: return [] p = pollard(n) if p == n: return [p] left = primefact(p) right = primefact(n // p) left += right return sorted(left) n = int(input()) lst = primefact(n) cnt = {} for l in lst: cnt[l] = cnt.get(l, 0) + 1 prod = 1 for v in cnt.values(): prod *= v + 1 if prod >= 4: print("YES") else: print("NO")