tyvj1109| N-Order Magic Square

Source: Internet
Author: User

Description
In a square consisting of several neatly arranged numbers, the sum of the numbers of any row, line, and diagonal in the graph is equal, and a chart of this nature is called the magic square.
It has been determined that the N-Order magic Square (n>=3) can construct the magic square.
our problem is, when constructing the magic square, the sum of the number of arbitrary rows is cumulative and how much.
Input Format
a number n means n-order magic square n<=10000
output Format
a number, a number of arbitrary rows, and an accumulation of
Test Sample 1
input
3

Output
the

Notes
Combinatorial Math Examples

Analysis: Set of formulas.

#include <iostream>usingnamespace  std; int Main () {    longlong n,ans=0;     >> N;    Ans= (1+n*n) *n/2;     <<

tyvj1109| N-Order Magic Square

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.