問題一覧 > 通常問題

No.2797 Square Tile

レベル : / AI推定難易度 : 1800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 53
作問者 : noya2 / テスター : shobonvip 👑 potato167
お気に入りにしたユーザー ProblemId : 11002 / 自分の提出
問題文最終更新日: 2024-06-28 21:02:58
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 435 (順位表) の他の問題:

Problem Statement

You are given positive integers $A,B$.

There are square tiles with side length $A$ and square tiles with side length $B$, with $A^2+B^2$ tiles of each kind.

Tile these on a $(A^2+B^2)\times (A^2+B^2)$ two-dimensional torus without gaps or overlaps.


Let us state this precisely. Let $L=A^2+B^2$.

Coordinates on the two-dimensional torus are denoted by $(x,y)$. $2$ coordinates $(x_1,y_1),(x_2,y_2)$ are considered the same if and only if $x_1-x_2, y_1-y_2$ are both integer multiples of $L$.

For integers $K,x,y$, placing a square tile with side length $K$ at coordinates $(x,y)$ means the following.

  • For all integers $i,j$ satisfying $0\le i\lt K, 0\le j\lt K$, the tile is placed so that it covers the coordinates $(x+i,y+j)$.

Moreover, the tiles being laid without gaps or overlaps means the following.

  • For all integers $i,j$ satisfying $0\le i\lt L, 0\le j\lt L$, the coordinates $(i,j)$ are covered by exactly $1$ tile.

It can be shown that a placement of the tiles satisfying the above conditions exists. Choose $1$ such placement and specify where to place each tile.

Constraints

  • All inputs are integers.
  • $1\le A,B\le 100$

Input

$A$ $B$

Output

Output $2(A^2+B^2)$ lines.

For $i=1,2,\dots ,A^2+B^2$, on the $i$-th line, output the following, where the $i$-th of the square tiles with side length $A$ is placed at $(x_i,y_i)$.

$x_i$ $y_i$

For $i=1,2,\dots ,A^2+B^2$, on line $A^2+B^2+i$, output the following, where the $i$-th of the square tiles with side length $B$ is placed at $(x_i,y_i)$.

$x_i$ $y_i$

In both cases above, $x_i,y_i$ must be integers satisfying $0\le x_i,y_i\lt A^2+B^2$.

Do not output any extra spaces or line breaks. Do not forget the final newline.

Sample

Sample 1
Input
1 2
Output
2 0
3 3
0 4
1 2
4 1
0 0
2 1
1 3
4 2
3 4

Sample 2
Input
1 1
Output
0 0
1 0
1 1
0 1

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。