結果
| 問題 |
No.1274 楽しい格子点
|
| コンテスト | |
| ユーザー |
nagiss
|
| 提出日時 | 2020-10-31 00:01:12 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 585 bytes |
| コンパイル時間 | 121 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 51,860 KB |
| 最終ジャッジ日時 | 2024-07-22 03:45:50 |
| 合計ジャッジ時間 | 60,557 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 50 WA * 7 |
ソースコード
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:
ans += 1 / ((ux+uy)**(ux+uy))
#print(ux, uy)
print(ans)
nagiss