結果

問題 No.1235 ζ関数
ユーザー TakaTaka
提出日時 2023-09-21 16:52:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 10,848 KB
実行使用メモリ 29,716 KB
最終ジャッジ日時 2023-09-21 16:52:40
合計ジャッジ時間 6,495 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
29,504 KB
testcase_01 AC 126 ms
29,500 KB
testcase_02 AC 125 ms
29,664 KB
testcase_03 AC 125 ms
29,524 KB
testcase_04 AC 151 ms
29,496 KB
testcase_05 AC 125 ms
29,492 KB
testcase_06 AC 123 ms
29,672 KB
testcase_07 AC 122 ms
29,536 KB
testcase_08 AC 123 ms
29,692 KB
testcase_09 AC 123 ms
29,672 KB
testcase_10 AC 122 ms
29,620 KB
testcase_11 AC 124 ms
29,700 KB
testcase_12 AC 126 ms
29,716 KB
testcase_13 AC 126 ms
29,488 KB
testcase_14 AC 125 ms
29,564 KB
testcase_15 AC 124 ms
29,664 KB
testcase_16 AC 125 ms
29,484 KB
testcase_17 AC 123 ms
29,564 KB
testcase_18 AC 124 ms
29,604 KB
testcase_19 AC 125 ms
29,688 KB
testcase_20 AC 122 ms
29,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 参考サイト:https://gist.github.com/edy555/5d950665e8b5f12f89bbf22ebf534043
# 問題URL:https://yukicoder.me/problems/no/1235

import numpy as np

LOWER_THRESHOLD=1.0e-6
UPPER_BOUND=1.0e+4
INFTY=400
def zeta_r(s):
    if s == 1:
        return np.NaN
    a = [0.5/(1-2**(1-s))]
    b = [a[0]]
    for n in range(1,INFTY):
        for k in range(n):
            a[k] = 0.5*a[k]*n/(n-k)
        a.append(-(float(n)/(n+1))**s * a[-1] / n)
        b.append(sum(a))
        if abs(b[-1]) < LOWER_THRESHOLD:
             break
        if abs(b[-1]) > UPPER_BOUND:
             break            
    return sum(b)
    
N = int(input())
print(zeta_r(N))
0