結果

問題 No.454 逆2乗和
ユーザー ukikagiukikagi
提出日時 2016-12-05 03:51:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 11,884 KB
最終ジャッジ日時 2023-08-20 03:15:30
合計ジャッジ時間 3,311 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
11,696 KB
testcase_01 AC 47 ms
11,852 KB
testcase_02 AC 43 ms
11,824 KB
testcase_03 AC 44 ms
11,856 KB
testcase_04 AC 43 ms
11,732 KB
testcase_05 AC 43 ms
11,724 KB
testcase_06 AC 42 ms
11,840 KB
testcase_07 AC 43 ms
11,696 KB
testcase_08 AC 44 ms
11,676 KB
testcase_09 AC 43 ms
11,780 KB
testcase_10 AC 43 ms
11,728 KB
testcase_11 AC 42 ms
11,760 KB
testcase_12 AC 42 ms
11,700 KB
testcase_13 AC 43 ms
11,728 KB
testcase_14 AC 43 ms
11,672 KB
testcase_15 AC 42 ms
11,736 KB
testcase_16 AC 43 ms
11,732 KB
testcase_17 AC 43 ms
11,808 KB
testcase_18 AC 43 ms
11,768 KB
testcase_19 AC 43 ms
11,728 KB
testcase_20 AC 44 ms
11,684 KB
testcase_21 AC 43 ms
11,884 KB
testcase_22 AC 44 ms
11,772 KB
testcase_23 AC 43 ms
11,860 KB
testcase_24 AC 43 ms
11,728 KB
testcase_25 AC 43 ms
11,752 KB
testcase_26 AC 43 ms
11,828 KB
testcase_27 AC 43 ms
11,768 KB
testcase_28 AC 43 ms
11,824 KB
testcase_29 AC 43 ms
11,864 KB
testcase_30 AC 43 ms
11,756 KB
testcase_31 AC 43 ms
11,696 KB
testcase_32 AC 43 ms
11,840 KB
testcase_33 AC 44 ms
11,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache

@lru_cache(maxsize = None)
def comb(n, k):
  if k == 0 or k == n:
    return 1
  else:
    return comb(n-1, k-1) + comb(n-1, k)

@lru_cache(maxsize = None)
def B(n):
  if n == 0:
    return 1
  else:
    return -sum(comb(n+1, k) * B(k) for k in range(0, n)) / (n+1)

def solve(x, N = 100, K = 100):
  S  = sum((x+n)**(-2) for n in range(1, N+1))
  S += 1/(x+N) - 0.5/(x+N)**2
  S += sum(B(2*k)*(x+N)**(-2*k-1) for k in range(1,K+1))
  return S

x = float(input())
print(solve(x))
0