結果

問題 No.1274 楽しい格子点
ユーザー nagissnagiss
提出日時 2020-10-31 00:07:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 615 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 49,512 KB
最終ジャッジ日時 2023-09-29 09:14:48
合計ジャッジ時間 23,435 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 707 ms
23,744 KB
testcase_02 RE -
testcase_03 AC 988 ms
48,940 KB
testcase_04 RE -
testcase_05 AC 960 ms
49,368 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 992 ms
49,308 KB
testcase_09 AC 965 ms
49,284 KB
testcase_10 AC 981 ms
49,476 KB
testcase_11 RE -
testcase_12 AC 961 ms
49,344 KB
testcase_13 AC 978 ms
49,444 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 956 ms
48,828 KB
testcase_17 AC 971 ms
49,300 KB
testcase_18 AC 955 ms
49,512 KB
testcase_19 AC 960 ms
48,856 KB
testcase_20 AC 1,003 ms
48,260 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 931 ms
48,368 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 AC 957 ms
48,380 KB
testcase_33 AC 926 ms
48,388 KB
testcase_34 AC 955 ms
48,508 KB
testcase_35 AC 976 ms
48,488 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 AC 931 ms
48,360 KB
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 AC 899 ms
45,420 KB
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 AC 727 ms
24,604 KB
testcase_55 AC 686 ms
21,876 KB
testcase_56 RE -
testcase_57 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
from collections import deque
A, B = map(int, input().split())
if A+B&1==0:
    assert False
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)
0