結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 WA -
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 WA -
testcase_07 AC 980 ms
49,456 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 WA -
testcase_15 AC 984 ms
49,404 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 972 ms
49,432 KB
testcase_22 AC 951 ms
48,504 KB
testcase_23 AC 954 ms
48,472 KB
testcase_24 AC 948 ms
48,480 KB
testcase_25 AC 935 ms
48,392 KB
testcase_26 AC 922 ms
48,408 KB
testcase_27 AC 946 ms
48,372 KB
testcase_28 RE -
testcase_29 AC 943 ms
48,424 KB
testcase_30 AC 935 ms
48,436 KB
testcase_31 AC 938 ms
48,448 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 942 ms
48,480 KB
testcase_37 AC 978 ms
48,408 KB
testcase_38 AC 963 ms
48,388 KB
testcase_39 AC 936 ms
48,396 KB
testcase_40 RE -
testcase_41 AC 960 ms
48,432 KB
testcase_42 AC 874 ms
45,236 KB
testcase_43 AC 906 ms
46,212 KB
testcase_44 RE -
testcase_45 AC 874 ms
45,264 KB
testcase_46 AC 850 ms
45,260 KB
testcase_47 AC 889 ms
45,696 KB
testcase_48 AC 944 ms
46,544 KB
testcase_49 AC 874 ms
45,384 KB
testcase_50 AC 926 ms
47,788 KB
testcase_51 AC 947 ms
47,152 KB
testcase_52 AC 19 ms
8,772 KB
testcase_53 AC 699 ms
23,776 KB
testcase_54 RE -
testcase_55 RE -
testcase_56 WA -
testcase_57 AC 733 ms
25,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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