Problem list
Log in
#r03521 · CCC 2016 Junior

Magic Squares

Bronze III 2.0 s 256 MB

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\times 4$ square of numbers, determine if it is magic square.

Input

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

Output

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

Example 1

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

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

Example 2

Input
5 10 1 3
10 4 2 3
1 2 8 5
3 3 5 0
Output
not magic

Notice that the top row adds up to 19, but the rightmost column adds up to 11.

Source
CCC 2016 Junior
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code