結果
| 問題 |
No.1274 楽しい格子点
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 00:11:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 799 bytes |
| コンパイル時間 | 217 ms |
| コンパイル使用メモリ | 82,508 KB |
| 実行使用メモリ | 71,872 KB |
| 最終ジャッジ日時 | 2025-04-16 00:13:02 |
| 合計ジャッジ時間 | 3,452 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 50 WA * 7 |
ソースコード
import math
A, B = map(int, input().split())
def compute_sum(A, B):
if A == 0 and B == 0:
return 0.25 # Only the initial position (1,1) is reachable
d = math.gcd(abs(A), abs(B))
if d == 0:
return 0.25 # This case is redundant as d is at least 1 if A or B is non-zero
res = 0.0
m = 0
while True:
k = 2 + d * m
term = (m + 1) / (k ** k)
res += term
if term < 1e-20: # Term is small enough to stop
break
m += 1
return res
result = compute_sum(A, B)
# Formatting the output to have enough decimal places and trimming trailing zeros
formatted_result = "{0:.30f}".format(result).rstrip('0').rstrip('.') if '.' in "{0:.30f}".format(result) else "{0:.30f}".format(result)
print(formatted_result)
lam6er