結果

問題 No.1278 どんな級数?
ユーザー lam6er
提出日時 2025-04-15 23:19:16
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 532 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 82,156 KB
実行使用メモリ 67,288 KB
最終ジャッジ日時 2025-04-15 23:20:40
合計ジャッジ時間 4,843 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 WA * 15 RE * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    X, K = map(int, sys.stdin.readline().split())
    if X == 1:
        ans = 1.0 - 1.0 / (2 ** (K + 1))
        print("{0:.9f}".format(ans))
    else:
        if K == 1:
            print("0.500000000")
        else:
            s = 0.0
            n = 2
            while True:
                term = 1.0 / (n ** K)
                if term < 1e-15 * s:
                    break
                s += term
                n += 1
            print("{0:.9f}".format(s))

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