URAL 1933 Guns for Battle!

135 篇文章 0 订阅
50 篇文章 0 订阅

Will: Load the guns.
Annamaria: With what?
Will: Anything. Everything.
Gibbs: Anything we have left. Load the guns! Case shot and langrage. Nails and crushed glass.
“Black Pearl” always had some problems with discipline. It is known that you should start solving big problems from solving smaller ones, that is why, firstly, Joshami Gibbs decided to find out who is responsible for servicing the guns during the battle.
It was pretty hard. There are n guns on the ship. All guns are quite heavy and difficult to use, so two gunners are necessary to serve one gun. Since there are 2 n + 1 gunners on board, one gunner has no pair in every battle. So, this pirate gets a role of commander during this battle.
Gibbs wants to make a schedule which will determine pairs of gunners and a commander for 2 n + 1 coming battles. Gibbs does not want the same pair of pirates to be on duty more than one time according the schedule because the pirates working in pairs bother each other. Moreover, if during 2 n + 1 battles one of the pirates is a commander twice or more, then Gibbs’s team will doubt in indifference of Gibbs, and it also leads to discipline problems. So many restrictions puzzled Joshami Gibbs. Help him make such schedule.

Input

The only line contains one integer n that is the number of gunners on board (1 ≤ n ≤ 100).

Output

Output 2 n + 1 lines each containing 2 n + 1 integers from 0 to 2 n + 1, j-th number in i-th line is equal to number of battle where gunners i and j serve the gun together. Battles are numbered from 1. i-th number in i-th line is 0.

Sample Input

inputoutput
1
0 1 2
1 0 3
2 3 0

给你2n+1个士兵 排成关于对角线对称的形式

#include<stdio.h>
#include<string.h>
int main()
{
	int n,i,j,a[300][300],z;
	while(~scanf("%d",&n))
	{
		n=n*2+1;
		memset(a,0,sizeof a);
		int k=1;
		int l=2;
		for(i=2;i<=n;i++)
		{
			if(k>n)
				k=1;
			for(z=0;z<l;z++)
			{
				if(i-z==z+1)
					continue;
				a[i-z][z+1]=k;
			}
			l++;
			k++;
		}
		for(i=1;i<n;i++)
		{
			if(k>n)
				k=1;
			for(z=1;z<l;z++)
			{
				if(n-z+1==z+i)
					continue;
				a[n-z+1][z+i]=k;
			}
	//		printf("%d %d\n",l,k);
			l--;
			
			k++;
		}


		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(j==1)
					printf("%d",a[i][j]);
				else printf(" %d",a[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值