Magic Square
Medium
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
A magic square is a grid where the sum of the numbers in each row and each column is identical; there are no requirements for the sums of the diagonals.
Your task is to construct such a square using a given set of numbers.
Input
The input file provides 16 distinct integers, each ranging from 0 to 32768.
Output
The output file should display the numbers arranged to form a 4×4 magic square, with each number appearing exactly once, arranged in four rows of four numbers each. If it is not possible to construct such a square, output the line NO SOLUTION.
Examples
Input #1
Answer #1
Submissions 94
Acceptance rate 16%