結果

問題 No.1278 どんな級数?
ユーザー gew1fw
提出日時 2025-06-12 13:59:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 495 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 82,764 KB
実行使用メモリ 67,396 KB
最終ジャッジ日時 2025-06-12 13:59:25
合計ジャッジ時間 7,449 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 15 RE * 26 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    X, K = map(int, sys.stdin.readline().split())
    
    if X == 1:
        result = 1.0 - (0.5 ** (K + 1))
        print("{0:.9f}".format(result))
    else:
        # Compute sum_{k=2}^infty 1/k^K
        sum_val = 0.0
        k = 2
        while True:
            term = 1.0 / (k ** K)
            if term < 1e-12:
                break
            sum_val += term
            k += 1
        print("{0:.9f}".format(sum_val))
    
if __name__ == "__main__":
    main()
0