QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 32 MB مجموع النقاط: 10

#11175. (K,N)-骑士 [B]

الإحصائيات

Bytean 象棋是世界上最奇特的象棋变种之一。由于游戏是在无限大的棋盘上进行的,进行每一场比赛都是一项巨大的挑战。Bytean 象棋爱好者们学习的基本能力是思考在数百万步移动后棋盘上所有可能的情况。为了做到这一点,他们需要知道给定的棋子是否能从一个指定的方格移动到另一个方格。

Bytean 象棋中最强大的棋子是 $(K,N)$-骑士。它的走法类似于传统象棋中的马。它的每一步移动由以下两种方式之一组成:先在垂直方向移动 $K$ 格,然后在水平方向移动 $N$ 格;或者先在垂直方向移动 $N$ 格,然后在水平方向移动 $K$ 格。因此,传统象棋中的马可以被看作是 $(2,1)$-骑士或 $(1,2)$-骑士。

任务是对于给定的两个棋盘方格,验证 $(K,N)$-骑士是否能从第一个方格移动到第二个方格(移动所需的步数并不重要)。

输入格式

标准输入的第一行包含一个整数 $T$ ($1 \le T \le 20\,000$),表示测试用例的数量。接下来的 $T$ 行中,每一行包含一个测试用例的描述,由六个整数 $K, N, x_1, y_1, x_2, y_2$ ($0 \le K, N \le 10^{9}$, $K+N > 0$, $-10^{9} \le x_1, y_1, x_2, y_2 \le 10^{9}$) 组成,并以空格分隔。$K$ 和 $N$ 描述了骑士的移动方式。骑士从方格 $(x_1, y_1)$ 开始移动。我们想要检查它是否能到达方格 $(x_2, y_2)$。

输出格式

对于每个测试用例,标准输出应写入一行。根据 $(K,N)$-骑士从方格 $(x_1, y_1)$ 出发是否能到达方格 $(x_2, y_2)$,输出 TAK(表示是)或 NIE(表示否)。

样例

输入 1

3
2 1 0 0 3 3
1 1 1 1 1 2
1 0 2 3 4 6

输出 1

TAK
NIE
TAK

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.