結果
問題 | No.1274 楽しい格子点 |
ユーザー |
![]() |
提出日時 | 2020-10-31 00:11:43 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 607 bytes |
コンパイル時間 | 71 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 51,940 KB |
最終ジャッジ日時 | 2024-07-22 18:44:16 |
合計ジャッジ時間 | 52,198 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 56 WA * 1 |
ソースコード
from math import gcd from collections import deque A, B = map(int, input().split()) G = gcd(A, B) 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: if not (A+B&1 == 0 and ux+uy&1): ans += 1 / ((ux+uy)**(ux+uy)) print(ans)