当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6440:Dream

Special Judge 特殊评判
题目描述
Freshmen frequently make an error in computing the power of a sum of real numbers, which usually origins from an incorrect equation $(m+n)^p = m^p + n^p$, where $m, n, p$ are real numbers. Let's call it ``Beginner's Dream''.

For instance, $(1+4)^2 = 5^2 = 25$, but $1^2 + 4^2 = 17 \ne 25$. Moreover, $\sqrt{9+16}=\sqrt{25}=5$, which does not equal $3+4=7$.

Fortunately, in some cases when $p$ is a prime, the identity
$$
(m+n)^p = m^p + n^p
$$
holds true for every pair of non-negative integers $m, n$ which are less than $p$, with appropriate definitions of addition and multiplication.

You are required to redefine the rules of addition and multiplication so as to make the beginner's dream realized.

Specifically, you need to create your custom addition and multiplication, so that when making calculation with your rules the equation $(m+n)^p=m^p+n^p$ is a valid identity for all non-negative integers $m,n$ less than $p$. Power is defined as
$$
a^p =
\left\{
\begin{array}{ll}
1, & p = 0 \\
a^{p-1} \cdot a, & p > 0
\end{array}
\right.
$$

Obviously there exists an extremely simple solution that makes all operation just produce zero. So an extra constraint should be satisfied that there exists an integer $q\:(0 < q < p)$ to make the set $\{ q^k \,|\, 0 < k < p, k \in \mathbb{Z} \}$ equal to $\{k\,|\,0<k<p,k\in\mathbb{Z}\}$. What's more, the set of non-negative integers less than $p$ ought to be closed under the operation of your definitions.

Hint

Hint for sample input and output:
From the table we get $0 + 1 = 1$, and thus $(0+1)^2 = 1^2 = 1\cdot{1} = 1$. On the other hand, $0^2 = 0\cdot{0} = 0$, $1^2 = 1\cdot{1}=1$, $0^2 + 1^2 = 0+1 = 1$.
They are the same.
输入解释
The first line of the input contains an positive integer $T\:(T \le 30)$ indicating the number of test cases.

For every case, there is only one line contains an integer $p\:(p < 2^{10})$, described in the problem description above. $p$ is guranteed to be a prime.
输出解释
For each test case, you should print $2p$ lines of $p$ integers.

The $j$-th($1 \le j \le p$) integer of $i$-th($1 \le i \le p$) line denotes the value of $(i-1) + (j-1)$. The $j$-th($1 \le j \le p$) integer of $(p+i)$-th($1 \le i \le p$) line denotes the value of $(i-1) \cdot (j-1)$.
输入样例
1
2
输出样例
0 1
1 0
0 0
0 1
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6440

最后修改于 2020-10-25T23:31:21+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
12000/6000MS(Java/Others) 65536/65536K(Java/Others)