#P15519. [CCC 2016 J2] Magic Squares

    ID: 17461 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度入门 上传者: 标签>2016CCC(加拿大)分类讨论

[CCC 2016 J2] Magic Squares

Problem Description

Magic Squares are square arrays of numbers that have the interesting property that the numbers in each column, and in each row, all add up to the same total.

Given a 4×44 \times 4 square of numbers, determine if it is a magic square.

Input Format

The input consists of four lines, each line having 44 space-separated integers.

Output Format

Output either magic if the input is a magic square, or not magic if the input is not a magic square.

16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
magic
5 10 1 3
10 4 2 3
1 2 8 5
3 3 5 0
not magic

Hint

Explanation for Output for Sample Input 1

Notice that each row adds up to 3434, and each column also adds up to 3434.

Explanation for Output for Sample Input 2

Notice that the top row adds up to 1919, but the rightmost column adds up to 1111.