結果
問題 |
No.1273 はじめのζ関数
|
ユーザー |
![]() |
提出日時 | 2025-04-15 22:30:41 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 636 bytes |
コンパイル時間 | 488 ms |
コンパイル使用メモリ | 81,916 KB |
実行使用メモリ | 65,364 KB |
最終ジャッジ日時 | 2025-04-15 22:32:32 |
合計ジャッジ時間 | 2,928 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 39 RE * 1 |
ソースコード
import math x = int(input()) if x == 2: print(1000000) elif x >= 20: # For large x, only the k=2 term is significant log_term = -(x - 1) * math.log(2) - math.log(1) term = math.exp(log_term) s = term else: # For small x, use the partial fraction decomposition approach sum_zeta = math.pi ** 2 / 6 # ζ(2) for i in range(3, x): z = 1.0 # ζ(i) starts with 1 for k=1 for k in range(2, 100000): term = 1.0 / (k ** i) if term < 1e-15: break z += term sum_zeta += z s = (x - 1) - sum_zeta result = int(s * 1e6) print(result)