結果
| 問題 | No.2750 Number of Prime Factors |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-10 21:25:26 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 851 bytes |
| 記録 | |
| コンパイル時間 | 124 ms |
| コンパイル使用メモリ | 85,208 KB |
| 実行使用メモリ | 52,352 KB |
| 最終ジャッジ日時 | 2026-05-27 08:13:21 |
| 合計ジャッジ時間 | 1,656 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
ソースコード
def MillerRabin_64bit(x):
if x <= 1:
return False
if x == 2:
return True
if x % 2 == 0:
return False
if x < 1 << 30:
test = [2, 7, 61]
else:
test = [2,325,9375,28178,450775,9780504,1795265022]
s = 0
d = x - 1
while d & 1 == 0:
s += 1
d >>= 1
for i in test:
if x <= i:
return True
y = pow(i,d,x)
if y == 1 or y == x - 1:
continue
c = 0
for j in range(s-1):
y = y * y % x
if y == x - 1:
c = 1
break
if not c:
return False
return True
n = int(input())
x = 2
ans = 1
for i in range(3,10000):
if x > n:
print(ans-1)
break
if MillerRabin_64bit(i) == False:
continue
ans += 1
x *= i