結果
問題 |
No.1274 楽しい格子点
|
ユーザー |
![]() |
提出日時 | 2020-10-31 00:04:12 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 589 bytes |
コンパイル時間 | 88 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 52,020 KB |
最終ジャッジ日時 | 2024-07-22 03:50:15 |
合計ジャッジ時間 | 57,738 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 38 WA * 19 |
ソースコード
from math import gcd from collections import deque A, B = map(int, input().split()) G = gcd(A, B) * 2 Closed = {(1, 1)} ans = 0.25 Dx = [G,0,-G,0,A,A,-A,-A,B,B,-B,-B] Dy = [0,G,0,-G,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 < 20 and 1 <= uy < 20: ans += 1 / ((ux+uy)**(ux+uy)) #print(ux, uy) print(ans)