結果
問題 |
No.1274 楽しい格子点
|
ユーザー |
![]() |
提出日時 | 2025-06-12 18:47:24 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 694 bytes |
コンパイル時間 | 369 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 72,352 KB |
最終ジャッジ日時 | 2025-06-12 18:47:44 |
合計ジャッジ時間 | 4,270 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 49 WA * 8 |
ソースコード
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()