1730: Tractatus Logico-Philosophicus
Time Limit: 1 Sec Memory Limit: 128 MB Special JudgeSubmit: 45 Solved: 26
[ Submit][ Status][ Web Board]
Description
This book is written by Ludwig Josef Johann Wittgenstein;
There are seven main propositions in the text. These are:
-
The world is everything that is the case.
-
What is the case (a fact) is the existence of states of affairs.
-
A logical picture of facts is a thought.
-
A thought is a proposition with a sense.
-
A proposition is a truth-function of elementary propositions. (An elementary proposition is a truth-function of itself.)
-
The general form of a proposition is the general form of a truth function, which is: . This is the general form of a proposition.
-
Whereof one cannot speak, thereof one must be silent.
Wittgenstein deduced our world was made up of logical word or logical picture.
There was a Conclution found by Wittgenstein that The most experienced Gods have to find a magic matrix of the size n × n (n is even number) to make our world .Matrix should contain integers from 0 to n - 1, main diagonal should contain only zeroes and matrix should be symmetric. Moreover, all numbers in each row and cloumn should be different. You found this secret after reading <<Tractatus Logico-Philosophicus>>.So output the world.
Input
The first line contains one integer T(1≤ T ≤ 10), There are T cases;
The next T lines contains one integer n( 2≤ n ≤ 1000) , n is even number.
Output
Output n lines with n numbers each for each case— the required matrix. Separate numbers with spaces. If there are several solutions, output any.
Sample Input
2
2
4
Sample Output
0 1
1 0
0 1 3 2
1 0 2 3
3 2 0 1
2 3 1 0
HINT
#include<iostream>
#include<set>
#include<map>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int INF=0x3f3f3f3f;
typedef long long LL;
const int N=30;
#define T 500+50
int num1[T][T],n,m,num2[T][T];
int main()
{
#ifdef cdzsc
freopen("in.txt","r",stdin);
#endif
int i,j,k;
scanf("%d",&n);
while(n--)
{
scanf("%d",&m);
int fj = m/2;
for(j=0;j<m;++j)
if(j<fj)num1[0][j]=j;
else num2[0][j-fj]=j;
for(i=1;i<fj;++i){
for(j=0;j<fj;++j){
num1[i][(j+1)%fj]=num1[i-1][j];
num2[i][(j+1)%fj]=num2[i-1][j];
}
}
for(i=0;i<fj;++i){
for(j=0;j<fj;++j)
printf("%d ",num1[i][j]);
for(j=0;j<fj;++j)
printf("%d ",num2[i][j]);
printf("\n");
}
for(i=0;i<fj;++i){
for(j=0;j<fj;++j)
printf("%d ",num2[i][j]);
for(j=0;j<fj;++j)
printf("%d ",num1[i][j]);
printf("\n");
}
}
return 0;
}