Puzzles
Third-order magic square. Try to fill in a 3x3 table with these 9 different integers, making the sum of the numbers on each row, each column, and each diagonal 1~9.
Strategy
Exhaustive search. Lists all the integer fill schemes, and then filters them.
JavaScript solution
Copy Code code as follows:
/**
* Created by Cshao on 12/28/14.
*/
function Getpermutation (arr) {
simulation has always been the NOIP must test a type of question is also the most simple type of questions generally speaking, this problem takes the least time and should try to take the most points, so as my "Noip real Problem" series of the first article on first say a simulation problem
Topics① Toy Puzzle "Noip Improvement Group" 2016d1t1 [difficulty]0.8 [tag]② Magical Magic Square "Noip raise Group" 20
Magic Square is a very magical n*n matrix: It is composed of digital three-way,..., n*n, and the sum of the numbers on each row, column, and two diagonal lines are the same. When N is an odd number, we can construct a magic square by the following method: First write 1 in the middle of the first line. Then, fill in eac
P1978 Magical Magic SquareDescribeMagic Square is a very magical n∗n matrix: It is made up of numbers, ..., n∗n, and the sum of the numbers on each row, column, and two diagonal lines are the same.When N is odd, we can construct a magic square by first writing 1 in the middle of the first line.Then, fill in each number
Magic Square is also known as Rubik's Cube, square squares or halls. In a square consisting of a number of neatly arranged numbers, the sum of the numbers of any one row, one longitudinal line, and the diagonal is equal, and a chart of this nature, called Magic
IOI ' The Magic Square (Magic version)The topic is translated by Jerryxie.Magic Square (Msqaure.cpp/c/pas)"Problem description"After the success of the Rubik's Cube, Mr. Lubic invented its two-dimensional version, called the Magic version. It is a table consisting of eight b
This paper illustrates the method of realizing the odd-order magic square in C language. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
#include "stdio.h"
#include "string.h"
#include "Stdlib.h"
#define N 5
void Main () {int a[n][n]={0};int i,j;int k;
i = 0;j = N/2;A[0][j]=1;for (k = 2; k if (i = = 0 J = = N-1) {//First, deter
Magical Magic Square.View Submit Statistics QuestionsTotal time limit: 1000ms memory limit: 65535kBDescribeThe Magic Square is a very magical n*n matrix, with each row, column and diagonal, the numbers combined are the same.We can build a magic square in the following ways.
When we see the sensitive geek words, we read this question first, and then calculate various la s on the paper...
Question: Construct an anti-Magic Square (which seems to be the opposite of the Magic Square ). It is actually a simple search rule,
My constructor: When the value is greater than or equal to the 5th order
This article describes how to implement the third-level magic square algorithm in JavaScript ~ 9 fill in the 9 different integers in a 3 #215; 3 table, so that the sum of numbers on each row, column, and each diagonal line is the same. For more information, see
Puzzles
Level 3 magic. Try 1 ~ 9 fill in the nine different integers in a 3 × 3 table, so that the s
// Huangfang. CPP: defines the entry point for the console application. // # include "stdafx. H "Void setvalue (unsigned char * HF, int howmuch, int X, int y, unsigned char value) {// fill in the magic square matrix * (HF + (Y-1) * howmuch + (X-1) = value;} unsigned char getvalue (unsigned char * HF, int howmuch, int X, int y) {// fill in the Magic
Noip Raise the group D1T1, has seen several times the question. But drag and drop, causing drag until today to AC off the topic.It seems that there is really nothing to say about this problem, it is the details.First the array must be initialized to 0, and then remember to continue.#include using namespacestd;inta[ A][ A],n;intMain () {Std::ios::sync_with_stdio (false); CIN>>N; inty= n/2+1, x=1; A[x][y]=1; for(intI=2; I i) { if(x==1 Y! =N) {x=N; ++y; A[x][y]=i; Continue; } if(Y==n
The method may be a bit stupid, take the first outer ring (1-12), and then the Middle (13-18) of the sorting method, so that the first pruning as far as possible to cut off three sums, and then remove four sum.But with arrays only, checking for repetition seems like a difficult thing to do, and the 12 results are actually one, 2 (mirror) *6 (angle)Original code, lhy1024#include Hex Magic square C language
Level n odd magic square
/* Level 3 matrix3*3 matrix, with a constant value (15)Analysis:Create a 3*3 two-dimensional array a [3] [3], assign num = 1 to a [0] [1], and save its subscript, the value in the upper-right corner of a [0] [1] is equal to num ++, which loops in sequence,The subscript will definitely be out of the range.Int ki = (I-1 + 3) % 3;Int kJ = (J + 1) % 3;It can be solvedIf an element exis
Puzzle: Third-order magic Square, try to fill in a 3x3 table with the 1~9 9 different integers, making the sum of the numbers on each row, each column, and each diagonal.
Strategy: Exhaustive search. Lists all the integer fill schemes, and then filters them.
The bright spot is the design of recursive function getpermutation, in the end, several non recursive algorithms are given.
Recursive algorithm,
Ethereum (J)
Ethereum (J) is a pure Java implementation of the Ethernet square protocol. It is provided as a library that can be embedded in any Java/scala project and provides full support for the Ethernet workshop agreement and ancillary services. Ethereum (J) was first developed by Roman Mandeleil and is now supported by
Ethereum (J) supports CPU mining. It
as 16 times put on the basis of the square once on it. and 16 times the square is 8 square. So and so on, we ask for 32 times only need 5 times of the powers: first squared, on the basis of the square of 4, on the basis of 4 to seek 8 square, on the basis of 8 to seek 16, a
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.