結果

問題 No.1273 はじめのζ関数
ユーザー lam6er
提出日時 2025-04-15 22:29:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,512 ms / 2,000 ms
コード長 514 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 81,752 KB
実行使用メモリ 75,604 KB
最終ジャッジ日時 2025-04-15 22:31:56
合計ジャッジ時間 4,088 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

x = int(input())

if x == 2:
    print(1000000)
elif x == 3:
    s = 2 - math.pi ** 2 / 6
    print(int(s * 1e6))
else:
    sum_S = 0.0
    k = 2
    eps = 1e-30  # Very small threshold to ensure precision
    while True:
        log_k = math.log(k)
        log_k_minus_1 = math.log(k - 1)
        log_term = log_k_minus_1 + (x - 1) * log_k
        term = math.exp(-log_term)
        if term < eps:
            break
        sum_S += term
        k += 1
    result = sum_S * 1e6
    print(int(result))
0