結果

問題 No.454 逆2乗和
ユーザー yuppe19 😺yuppe19 😺
提出日時 2016-12-26 00:02:01
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 6,724 KB
実行使用メモリ 6,140 KB
最終ジャッジ日時 2023-08-20 03:33:10
合計ジャッジ時間 1,738 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,972 KB
testcase_01 AC 12 ms
5,988 KB
testcase_02 AC 12 ms
6,136 KB
testcase_03 AC 12 ms
5,988 KB
testcase_04 AC 11 ms
5,984 KB
testcase_05 AC 11 ms
5,984 KB
testcase_06 AC 11 ms
5,968 KB
testcase_07 AC 11 ms
5,908 KB
testcase_08 AC 11 ms
6,048 KB
testcase_09 AC 11 ms
6,048 KB
testcase_10 AC 11 ms
6,112 KB
testcase_11 AC 11 ms
6,140 KB
testcase_12 AC 11 ms
5,908 KB
testcase_13 AC 10 ms
6,052 KB
testcase_14 AC 11 ms
5,968 KB
testcase_15 AC 10 ms
6,116 KB
testcase_16 AC 11 ms
6,132 KB
testcase_17 AC 10 ms
5,972 KB
testcase_18 AC 11 ms
6,132 KB
testcase_19 AC 11 ms
6,124 KB
testcase_20 AC 11 ms
6,048 KB
testcase_21 AC 11 ms
6,044 KB
testcase_22 AC 11 ms
5,968 KB
testcase_23 AC 11 ms
6,108 KB
testcase_24 AC 11 ms
6,112 KB
testcase_25 AC 11 ms
5,992 KB
testcase_26 AC 11 ms
6,120 KB
testcase_27 AC 11 ms
5,912 KB
testcase_28 AC 11 ms
6,052 KB
testcase_29 AC 11 ms
5,912 KB
testcase_30 AC 11 ms
5,968 KB
testcase_31 AC 11 ms
6,124 KB
testcase_32 AC 10 ms
6,052 KB
testcase_33 AC 11 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
from math import pi, sin

def trigamma(x):
    small = 1e-4
    large = 8
    f1 = float(1)

    if x <= 0 and int(x) == x:
        return float('inf')
    if x < 0:
        val = pi / sin(-pi * x)
        return -trigamma(1-x) + val*val
    if x <= small:
        c = pi * pi / 6 # Zeta(2)
        c1 = -2.404113806319188570799476  # -2 Zeta(3)
        return f1 / (x*x) + c + c1*x
    val = 0.
    while x < large:
        val += f1 / (x*x)
        x += 1
    if x >= large:
        r = f1 / (x*x)
        bs = [f1, f1/6, -f1/30, f1/42, -f1/30, f1*5/66]
        val += .5*r + reduce(lambda by, bx: bx + r*by, reversed(bs)) / x
    return val

x = float(raw_input())
res = trigamma(x+1)
print '{:.15f}'.format(res)
0