結果

問題 No.2797 Square Tile
ユーザー hitonanode
提出日時 2024-06-29 01:36:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 941 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,632 KB
最終ジャッジ日時 2024-06-29 01:36:31
合計ジャッジ時間 3,716 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def solve(A: int, B: int):
    L = A * A + B * B

    retA: list[tuple[int, int]] = []
    retB: list[tuple[int, int]] = []

    for idx in range(L):
        if A > B:
            retA.append((B * idx % L, A * idx % L))
            retB.append((B * idx % L, A * (idx + 1) % L))
        else:
            retA.append((A * idx % L, B * (idx + 1) % L))
            retB.append((A * idx % L, B * idx % L))
    
    return retA, retB

A, B = map(int, input().split())

G = math.gcd(A, B)

tmpA, tmpB = solve(A // G, B // G)

# print(A, B, G, tmpA, tmpB)

retA: list[tuple[int, int]] = []
retB: list[tuple[int, int]] = []

for x in range(G):
    for y in range(G):
        for a, b in tmpA:
            retA.append((a * G + x * A // G, b * G + y * B // G))
        for a, b in tmpB:
            retB.append((a * G + x * A // G, b * G + y * B // G))

for a, b in sorted(retA):
    print(a, b)
for a, b in sorted(retB):
    print(a, b)
0