Problem A. Another Chess Problem

时间限制 1000 ms   内存限制 128 MB

You are given an infinite set $S = \left\{(x, y)|x, y \in Z, \lnot \exists i, j \in Z \; s.t. \; x = 2i + j,y = i - 2j \right\}$ and two pairs $(x_1, y_1), (x_2, y_2) \in S$.

You have a pair $(x, y)$ in your right pocket which equals to $(x_1, y_1)$ in the beginning. You can pay Y_UME a coin at a time and then change $(x, y)$ to one element in S whose distance to $(x, y)$ is $1$. The distance between $(a_1, b_1)$ and $(a_2, b_2)$ is defined as $|a_1-a_2| + |b_1-b_2|$.

You expect to get $(x_2, y_2)$ and minimize the number of coins given to Y_UME. Output the minimum number of coins and output the number of different ways to achieve the goal modulo $998244353$.

Note that two ways differ if and only if there exsits some $i$ such that $i$-th steps in the two ways are different.
 

输入数据

The first line contains one positive integer $T(T \leq 2 \times 10^5)$ denoting the number of test cases.

Each case starts with a line containing four integers $x_1, y_1, x_2, y_2(-10^5 \leq x_1, y_1, x_2, y_2 \leq 10^5)$.
 

输出数据

For each test case, output one line containing two integers denoting the minimum number of coins and the number of different ways modulo $998244353$.
 

样例输入

复制
3
1 1 5 2
1 1 2 5
1 1 1 1

样例输出

复制
7 5
5 1
0 1

提交

请先 登录

© 2025 FAQs Contact About