시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB22816115174.384%

문제

A magic square is an arrangement of integers in a square grid, where the numbers in each row, and in each column, and the numbers on each main diagonal, all add up to the same value. A magic square has the same number of rows and columns and we will let m represent the size (number of rows and columns) of the magic square. Thus, a magic square of size m will have a total of m2 integers. The following is a magic square with m=3.

You will write a program that will determine if an mxm square is a magic square.

입력

The first line of input will be a positive integer, n, indicating the number of problem sets (i.e., magic squares) to follow. Each problem set starts with the integer, m, that specifies the size of the magic square. The next m lines each contain m integers and the integers are separated by one or more spaces.

출력

For each problem set if the square is a magic square print “Magic square of size <m>”, where <m> is replaced with the size (number of rows) of the magic square. If the square is not a magic square print “Not a magic square”

제한

  • 2 ≤ m ≤ 5

예제 입력 1

4
3
2 7 6
9 5 1
4 3 8
2
14 22
26 10
4
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
2
5 5
5 5

예제 출력 1

Magic square of size 3
Not a magic square
Magic square of size 4
Magic square of size 2

출처

High School > PLU High School Programming Contest > PLU 2014 > Novice 8번

  • 빠진 조건을 찾은 사람: jaehoo1
  • 문제의 오타를 찾은 사람: jh05013
  • 잘못된 데이터를 찾은 사람: tncks0121