結果

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

ソースコード

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((B * idx % L, A * (idx + 1) % L))
            retB.append((B * idx % L, A * idx % L))
    
    return retA, retB

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

G = math.gcd(A, B)
# print(A, B, G)

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

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