CSU1730-Tractatus Logico-Philosophicus(模拟)

1730: Tractatus Logico-Philosophicus

Time Limit: 1 Sec   Memory Limit: 128 MB   Special Judge
Submit: 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:

  1. The world is everything that is the case.

  2. What is the case (a fact) is the existence of states of affairs.

  3. A logical picture of facts is a thought.

  4. A thought is a proposition with a sense.

  5. A proposition is a truth-function of elementary propositions. (An elementary proposition is a truth-function of itself.)

  6. The general form of a proposition is the general form of a truth function, which is: [\bar p,\bar\xi, N(\bar\xi)] . This is the general form of a proposition.

  7. 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


题意:
   要你找出横竖都不相同的矩阵,这题一开始根本没有思路,但是突然看到了第二个数据有点诡异,交叉在一起了,所以就想到每两个是一个2*2的矩阵,最后在推6*6矩阵发现不对。因为出现了奇数的矩阵了,所以不能有奇数的,所以就想到会不会是都是分为两个呢?最后发现是正确的,每行只是上一行的向后推一位。

AC代码:

#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;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值