結果

問題 No.1274 楽しい格子点
ユーザー nagiss
提出日時 2020-10-30 23:59:02
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 27,644 KB
最終ジャッジ日時 2024-07-22 03:40:40
合計ジャッジ時間 39,667 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 50 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
from collections import deque
A, B = map(int, input().split())
A, B = gcd(A, B), 0
Closed = {(1, 1)}
ans = 0.25
Dx = [A,A,-A,-A,B,B,-B,-B]
Dy = [B,-B,B,-B,A,-A,A,-A]
q = deque([(1, 1)])
for i in range(10**5):
    if not q:
        break
    x, y = q.popleft()
    for dx, dy in zip(Dx, Dy):
        ux, uy = x+dx, y+dy
        if (ux, uy) not in Closed:
            Closed.add((ux, uy))
            q.append((ux, uy))
            if 1 <= ux < 50 and 1 <= uy < 50:
                ans += 1 / ((ux+uy)**(ux+uy))
                #print(ux, uy)
print(ans)
0