yukicoder-217
从 Trac 迁移的文章
这是从旧校内 Wiki 迁移的文章,可能存在一些样式问题,您可以向 memset0 反馈。
原文章内容如下:
{{{
#!html
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});</script>
<script type="text/javascript" async src="http://10.71.10.90/sfiction/tool/MathJax/MathJax-master/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<style>
.input, pre {
display: block;
padding: 9.5px;
margin: 0 0 10px;
font-size: 13px;
line-height: 1.42857143;
color: #333;
word-break: break-all;
word-wrap: break-word;
background-color: #f5f5f5;
border: 1px solid #ccc;
border-radius: 4px;
}
</style>
}}}
== [https://yukicoder.me/problems/no/217 No.217 魔方陣を作ろう] ==
=== Description ===
{{{
#!html
<p>给出$N$,构造一个$N \times N$的幻方(方阵的每行、每列以及两条对角线的和都等于常数$\frac{N(N^2+1)}{2}$)。</p>
<p>如下是$3 \times 3$的幻方</p>
<pre>
2 9 4
7 5 3
6 1 8
</pre>
}}}
=== Input ===
{{{
#!html
<p class="input">
$N$
</p>
<p>
一个整数$N$ ($3 \le N \le 20$)。</p>
}}}
=== Output ===
{{{
#!html
<p class='input'>
$A_{1,1}$ $A_{1,2}$ $\dots$ $A_{1,N}$<br>
$A_{2,1}$ $A_{2,2}$ $\dots$ $A_{2,N}$<br>
$\vdots$<br>
$A_{N,1}$ $A_{N,2}$ $\dots$ $A_{N,N}$
</p>
}}}
=== Sample ===
==== Sample 1 ====
输入
{{{
#!html
<pre>
3
</pre>
}}}
输出
{{{
#!html
<pre>
2 9 4
7 5 3
6 1 8
</pre>
}}}
No.217 魔方陣を作ろう
Description
给出$N$,构造一个$N \times N$的幻方(方阵的每行、每列以及两条对角线的和都等于常数$\frac{N(N^2+1)}{2}$)。
如下是$3 \times 3$的幻方
2 9 47 5 36 1 8
Input
$N$
一个整数$N$ ($3 \le N \le 20$)。
Output
$A_{1,1}$ $A_{1,2}$ $\dots$ $A_{1,N}$
$A_{2,1}$ $A_{2,2}$ $\dots$ $A_{2,N}$
$\vdots$
$A_{N,1}$ $A_{N,2}$ $\dots$ $A_{N,N}$
Sample
Sample 1
输入
3
输出
2 9 47 5 36 1 8