結果
| 問題 | No.3691 Calculate Mu Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-06 22:53:12 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 961 ms / 2,000 ms |
| + 567µs | |
| コード長 | 555 bytes |
| 記録 | |
| コンパイル時間 | 233 ms |
| コンパイル使用メモリ | 96,212 KB |
| 実行使用メモリ | 631,808 KB |
| 最終ジャッジ日時 | 2026-09-06 22:53:24 |
| 合計ジャッジ時間 | 6,496 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 |
ソースコード
# https://tjkendev.github.io/procon-library/python/prime/moebius-function.html
# a table of μ(n) for n in [1, N]
# O(N log log N)
def moebius_table(n):
*p, = range(n+1)
sq = int(n**.5)
for x in range(2, sq+1):
if p[x] == x:
for y in range(x*x, n+1, x):
p[y] = x
for y in range(x*x, n+1, x*x):
p[y] = 0
res = [0]*(n+1)
res[0] = 0; res[1] = 1
for x in range(2, n+1):
res[x] = (p[x] and -res[x//p[x]])
return res
print(sum(moebius_table(int(input()))[1:]))