URAL 1933 Guns for Battle!
来源:互联网 发布:mac seesheer试色 编辑:程序博客网 时间:2024/05/16 07:39
给一个n,要求构造一个矩阵,满足:
1、矩阵大小为(2n+1)*(2n+1)
2、沿对角线对称
3、每个数的值在[0,2n+1]上
4、每行每列没有重复的值
手动写了一下 直接找到规律。。
#include<cstdio>#include<cstring>using namespace std;int n,m,i,j,cnt,s[205][205],k;int main(){ while(~scanf("%d",&n)) { m=2*n+1; cnt=1; for(i=0;i<m;i++,cnt--) { if(cnt==-1) cnt=m-1; for(j=cnt,k=1;k<=m;j++,k++) { if(j==m) j=0; s[i][j]=k; } s[i][i]=0; } for(i=0;i<m;i++) { for(j=0;j<m-1;j++) printf("%d ",s[i][j]); printf("%d\n",s[i][m-1]); } } return 0;}
0 0
- ural 1933 Guns for Battle!
- URAL 1933 Guns for Battle!
- URAL 1933 Guns for Battle!
- Ural 1540. Battle for the Ring
- Ural 1991 The battle near the swamp
- URAL 1991. The battle near the swamp
- nwerc2013 B - Battle for Silver
- Ural1540 Battle for the Ring
- (校赛)URAL 1991 The battle near the swamp
- URAL 1439. Battle with You-Know-Who treap树
- Battle
- UESTC889&&uvalive6623 Battle for Silver(dfs)
- UESTC 889 Battle for Silver (dfs)
- Ural 1787. Turn for MEGA
- URAL 1787. Turn for MEGA
- URAL 2005. Taxi for Programmers
- 经典永恒--21guns
- 独立思考Justic:Hired Guns
- UVa452 - Project Scheduling(AOE问题)
- sgu103
- poj 1703 poj1182(并查集)
- 【2014.0804】
- 完全匹配-最大匹配
- URAL 1933 Guns for Battle!
- Total Commander 搜索指定类型并且包含特定内容的文件
- 文本处理
- 64位系统下注册32位dll文件
- ACM中的C++
- poj2456Aggressive cows(二分+贪心)
- php 二分查找法算法详解
- HDU 2955
- iOS 监听textfield的输入