MNS
SRM 148 · 2003-05-28 · by chogyonim
Problem Statement
9 numbers need to be arranged in a magic number square. A magic number square is a square of numbers that is arranged such that every row and column has the same sum. For example:
1 2 3 3 2 1 2 2 2
Create a class MNS containing a method combos which takes as an argument a
Notes
- Unlike some versions of the magic number square, the numbers do not have to be unique.
Constraints
- numbers will contain exactly 9 elements.
- each element of numbers will be between 0 and 9, inclusive.
{1,2,3,3,2,1,2,2,2}
Returns: 18
{4,4,4,4,4,4,4,4,4}
Returns: 1
{1,5,1,2,5,6,2,3,2}
Returns: 36
{1,2,6,6,6,4,2,6,4}
Returns: 0
{1,2,3,4,5,6,7,8,9}
Returns: 72
Submissions are judged against all 23 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class MNS with a public method int combos(vector<int> numbers) · 23 test cases · 2 s / 256 MB per case