結果

問題 No.1274 楽しい格子点
ユーザー gew1fw
提出日時 2025-06-12 13:34:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 694 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 82,536 KB
実行使用メモリ 72,568 KB
最終ジャッジ日時 2025-06-12 13:40:17
合計ジャッジ時間 4,489 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 49 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def main():
    A, B = map(int, input().split())
    a, b = A, B
    d = math.gcd(abs(a), abs(b))
    result = 0.0
    threshold = 1e-20  # Threshold to stop iteration when terms become negligible
    max_k = 1000  # Upper limit to prevent infinite loops in case of unexpected scenarios
    
    for k in range(0, max_k + 1):
        S = 2 + d * k
        term = (k + 1) / (S ** S)
        if term < threshold:
            break
        result += term
    
    # Formatting the output to have enough decimal places
    print("{0:.30f}".format(result).rstrip('0').rstrip('.') if '.' in "{0:.30f}".format(result) else "{0:.30f}".format(result))

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