結果
| 問題 |
No.1278 どんな級数?
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 23:21:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 710 bytes |
| コンパイル時間 | 203 ms |
| コンパイル使用メモリ | 81,868 KB |
| 実行使用メモリ | 67,500 KB |
| 最終ジャッジ日時 | 2025-04-15 23:23:38 |
| 合計ジャッジ時間 | 4,704 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 15 RE * 37 |
ソースコード
import sys
import math
def main():
X, K = map(int, sys.stdin.readline().split())
if X == 1:
result = 1.0 - 1.0 / (2 ** (K + 1))
print("{0:.10f}".format(result))
elif X == 2:
if K == 1:
print(0.5)
else:
# For K >= 2, approximate zeta(K) - 1 using the series sum_{n=2}^infty 1/n^K
# Compute until the terms are smaller than 1e-15
zeta_k = 0.0
n = 2
while True:
term = 1.0 / (n ** K)
if term < 1e-15:
break
zeta_k += term
n += 1
print("{0:.10f}".format(zeta_k))
if __name__ == "__main__":
main()
lam6er