結果

問題 No.454 逆2乗和
ユーザー はむ吉🐹
提出日時 2017-01-01 21:51:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-12-16 05:11:35
合計ジャッジ時間 2,406 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

import fractions


def inv(x):
    return fractions.Fraction(1, x)


# http://www.cis.nagasaki-u.ac.jp/~masada/Digamma2010042801.pdf
def trigamma(x):
    ans = inv(x)
    ans += inv(2 * x ** 2)
    ans += inv(6 * x ** 3)
    ans -= inv(30 * x ** 5)
    ans += inv(42 * x ** 7)
    ans -= inv(30 * x ** 9)
    ans += 5 * inv(66 * x ** 11)
    ans -= 691 * inv(2730 * x ** 13)
    ans += 7 * inv(6 * x ** 15)
    return ans


def main():
    x = fractions.Fraction(input())
    if x == 0:
        res = 1.6449340668482426
    else:
        res = trigamma(x + 1)
    print("{:.16f}".format(float(res)))


if __name__ == '__main__':
    main()
0