結果
問題 | No.2797 Square Tile |
ユーザー |
![]() |
提出日時 | 2024-06-29 01:39:16 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 120 ms / 2,000 ms |
コード長 | 947 bytes |
コンパイル時間 | 268 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 21,760 KB |
最終ジャッジ日時 | 2024-06-29 01:39:20 |
合計ジャッジ時間 | 3,080 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
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]] = [] s = (A * A + B * B) // G for x in range(G): for y in range(G): for a, b in tmpA: retA.append((a * G + x * s, b * G + y * s)) for a, b in tmpB: retB.append((a * G + x * s, b * G + y * s)) for a, b in sorted(retA): print(a, b) for a, b in sorted(retB): print(a, b)