Magic Squares
Time limit2sMemory limit512 MB
Given a 4x4 grid, check whether all four row sums and all four column sums are equal, then print whether it is magic.
- Level
Easy2 of 10
- Topics
- Implementation, Matrix
- Solved
- No attempts yet
Problem
A magic square is a square array of numbers in which every row sums to the same total and every column sums to that same total.
A array of integers is given. Decide whether it is a magic square. This problem compares the four row sums and the four column sums only, and does not look at the diagonals.
Input
The input consists of four lines. Each line holds 4 space-separated integers.
Output
Print magic if the input is a magic square, or not magic if it is not.