怎么做企业招聘网站,舆情网站大全,化妆品企业网站源码,wordpress调整配置出错了传送门 文章目录题意#xff1a;思路#xff1a;题意#xff1a;
给你一个奇数nnn#xff0c;构造一个nnn阶幻方。 3≤n≤193\le n\le 193≤n≤19
思路#xff1a;
模板题了#xff0c;直接构造一个幻方即可。
首先在第一行中间放一个111#xff0c;之后每次看一下(…传送门 文章目录题意思路题意
给你一个奇数nnn构造一个nnn阶幻方。
3≤n≤193\le n\le 193≤n≤19
思路
模板题了直接构造一个幻方即可。
首先在第一行中间放一个111之后每次看一下(x,y)(x,y)(x,y)右上角的位置(x−1,y1)(x-1,y1)(x−1,y1)是否已经被放过数了如果没有下一个数就放过去否则就放到这个位置的下面(x1,y)(x1,y)(x1,y)即可。
// Problem: C. Magic Odd Square
// Contest: Codeforces - Educational Codeforces Round 16
// URL: https://codeforces.com/problemset/problem/710/C
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)//#pragma GCC optimize(Ofast,no-stack-protector,unroll-loops,fast-math)
//#pragma GCC target(sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tunenative)
//#pragma GCC optimize(2)
#includecstdio
#includeiostream
#includestring
#includecstring
#includemap
#includecmath
#includecctype
#includevector
#includeset
#includequeue
#includealgorithm
#includesstream
#includectime
#includecstdlib
#includerandom
#includecassert
#define X first
#define Y second
#define L (u1)
#define R (u1|1)
#define pb push_back
#define mk make_pair
#define Mid ((tr[u].ltr[u].r)1)
#define Len(u) (tr[u].r-tr[u].l1)
#define random(a,b) ((a)rand()%((b)-(a)1))
#define db puts(---)
using namespace std;//void rd_cre() { freopen(d://dp//data.txt,w,stdout); srand(time(NULL)); }
//void rd_ac() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//AC.txt,w,stdout); }
//void rd_wa() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//WA.txt,w,stdout); }typedef long long LL;
typedef unsigned long long ULL;
typedef pairint,int PII;const int N1000010,mod1e97,INF0x3f3f3f3f;
const double eps1e-6;int n;
int a[100][100];int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);cinn;int x0,yn/2,now1;a[x][y]now;for(int i2;in*n;i,now) {int dx(x-1n)%n,dy(y1)%n;if(a[dx][dy]) {dx(x1)%n,dyy;a[dx][dy]now;} else a[dx][dy]now;xdx; ydy;}for(int i0;in;i) {for(int j0;jn;j) {printf(%d ,a[i][j]);}puts();}return 0;
}
/**/