結果
問題 | No.454 逆2乗和 |
ユーザー |
![]() |
提出日時 | 2025-03-26 15:55:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 1,278 bytes |
コンパイル時間 | 1,162 ms |
コンパイル使用メモリ | 82,320 KB |
実行使用メモリ | 54,360 KB |
最終ジャッジ日時 | 2025-03-26 15:56:18 |
合計ジャッジ時間 | 2,834 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
import mathdef trigamma(x):if x >= 10:return trigamma_asymptotic(x)else:m = max(0, math.ceil(10 - x))sum_part = sum(1.0 / (x + k)**2 for k in range(m))return sum_part + trigamma(x + m)def trigamma_asymptotic(x):result = 1.0 / xresult += 1.0 / (2 * x**2)result += 1.0 / (6 * x**3)# Terms from Bernoulli numbers up to B_20terms = [(-1/30, 5), # B_4 term: -1/(30*2x^5) → -1/(60x^5)(1/42, 7), # B_6 term: 1/(42*3x^7) → 1/(126x^7)(-1/30, 9), # B_8 term: -1/(30*4x^9) → -1/(120x^9)(5/66, 11), # B_10 term:5/(66*5x^11) → 1/(66x^11)(-691/2730, 13), # B_12 term: -691/(2730*6x^13)(7/6, 15), # B_14 term:7/(6*7x^15) →1/(6x^15)(-3617/510, 17), # B_16 term:-3617/(510*8x^17)(43867/798, 19), # B_18 term:43867/(798*9x^19)(-174611/330, 21)# B_20 term:-174611/(330*10x^21)]for B, exponent in terms:term = B / (x ** exponent)result += termif abs(term) < 1e-20:breakreturn resultx = float(input().strip())if x == 0:print("{0:.15f}".format(math.pi**2 / 6))else:s = x + 1.0result = trigamma(s)print("{0:.15f}".format(result))