Statistics

Problem Statement for "MatArith"

Problem Statement

Let an R by C (also notated as RxC) matrix mean a matrix with R rows and C columns. Also, for x between 1 and R, inclusive, and y between 1 and C inclusive, let element (x,y) represent the element at the xth row and yth column (both 1-indexed) of a given R by C matrix.

Matrix multiplication works as follows:

For an L by M matrix A and an M by N matrix B, define an L by N matrix P such that A * B = P, and each element (x,y) of matrix P is equal to the sum of the product of each element of the xth row of A with the equivalently indexed element of the yth column of B.

For example, say we have a 4x2 matrix A and a 2x3 matrix B:

A={{ a1, a2 },
   { a3, a4 },
   { a5, a6 },
   { a7, a8 }}

B={{ b1, b2, b3 },
   { b4, b5, b6 }}

Then 4x3 matrix P = A * B =
{{ b1*a1+b4*a2, b2*a1+b5*a2, b3*a1+b6*a2 },
 { b1*a3+b4*a4, b2*a3+b5*a4, b3*a3+b6*a4 },
 { b1*a5+b4*a6, b2*a5+b5*a6, b3*a5+b6*a6 },
 { b1*a7+b4*a8, b2*a7+b5*a8, b3*a7+b6*a8 }}

Matrix addition works as follows:

For an L by M matrix A and an L by M matrix B, define an L by M matrix S such that A + B = S, and each element (x,y) of matrix C is equal to the sum of the two elements (x,y) in A and B.

For example, say we have a 2x3 matrix A and a 2x3 matrix B:

A={{ a1, a2, a3 },
   { a4, a5, a6 }}

B={{ b1, b2, b3 },
   { b4, b5, b6 }}

Then 2x3 matrix S = A + B =
{{ a1+b1, a2+b2, a3+b3 }
 { a4+b4, a5+b5, a6+b6 }}

Write a method multiply which takes three String[] inputs representing matrix A, matrix B, and matrix C. Each element will be a String representing a row of that matrix as follows:

"I1 I2 I3 I4 I5 ... IN" (quotes added for clarity)

where each I is an integer.

The fourth argument is a String representing an equation between A, B, and C.

Return the String[] represention of the solution matrix to the equation, in the same form as the inputs.

The equation follows the standard order of operations. That is, first do any multiplications, going left to right. Then do any additions, going left to right. After each multiplication or addition, put an intermediate matrix in place of the two argument matrices. For example (quotes added for clarity):

"A*B+C*A"

You would first multiply A*B, and replace those two matrices with an intermediate matrix M:

"M+C*A"

You would then multiply C*A, and replace those two matrices with an intermediate matrix N:

"M+N"

You would finally add M+N, returning the final result.

If the equation is not valid for the given matrices, return an empty String[]. The equation is not valid if:

*at any point, two matrices (A, B, C, or any intermediates) must be multiplied, in which the number of rows in the second matrix is not equal to the number of columns in the first matrix.

*at any point, two matrices (A, B, C, or any intermediates) must be added, but do not have the same dimensions.

*at any point, one of the intermediate matrices contains a value that is greater than 2147483647 or less than -2147483648.

In summary, given the 3 matrices and an equation involving those three matrices, return the resulting matrix in the described String[] format, or an empty String[] if the equation is not valid for the given matrices.

Definition

Class:
MatArith
Method:
calculate
Parameters:
String[], String[], String[], String
Returns:
String[]
Method signature:
String[] calculate(String[] A, String[] B, String[] C, String equation)
(be sure your method is public)

Notes

  • The return must be formatted exactly as the inputs. That means no leading/trailing or extra spaces.

Constraints

  • Each String[] will contain 1 to 10 element, inclusive.
  • Each element of A, B and C will contain between 1 and 50 characters, inclusive.
  • All elements of A, B and C will be a space-delimited list of integers, with one space between integers, and no leading or trailing spaces.
  • All elements of A, B and C will contain only the numbers [0-9] inclusive, the negative sign ('-') and spaces.
  • The number of integers represented by each element of A, B and C will be between 1 and 10, inclusive.
  • The number of integers represented by each element of A will be the same as the number of integers represented by every other element of A.
  • The number of integers represented by each element of B will be the same as the number of integers represented by every other element of B.
  • The number of integers represented by each element of C will be the same as the number of integers represented by every other element of C.
  • Each integer represented in A, B or C will be between -10 and 10, inclusive.
  • Each integer represented in A, B or C will be a correctly formatted integer, without leading zeros.
  • equation will contain between 1 and 49 characters, inclusive.
  • equation can only contain the capital letters 'A', 'B', and 'C', and the two operands '+' and '*'.
  • The first and last characters of equation will be letters, and each pair of consecutive letters in equations will have exactly one operand between them.

Examples

  1. {"1 2 3","2 3 4"}

    {"1 2","3 4","5 6"}

    {"1"}

    "A*B"

    Returns: { "22 28", "31 40" }

    A*B={{ 1*1+2*3+3*5, 1*2,2*4,3*6 }, { 2*1+3*3+4*5, 2*2+3*4+4*6 }}

  2. {"1 2 3","2 3 4"}

    {"1 2","3 4","5 6"}

    {"1"}

    "A+B+C"

    Returns: { }

    A+B is calculated first, but the two matrices do not have the same dimensions.

  3. {"3 5 7","5 4 3","-2 3 2"}

    {"3"}

    {"1 1 1","2 5 2","3 5 -3"}

    "A+C"

    Returns: { "4 6 8", "7 9 5", "1 8 -1" }

    A+C={{ 3+1, 5+1, 7+1 }, { 2+5, 5+4, 2+3 }, { -2+3, 3+5, 2+-3 }}

  4. {"10 0","0 0"}

    {"0"}

    {"0"}

    "A*A*A*A*A*A*A*A*A"

    Returns: { "1000000000 0", "0 0" }

  5. {"10 0","0 0"}

    {"0"}

    {"0"}

    "A*A*A*A*A*A*A*A*A*A"

    Returns: { }

    An intermediate value (10,000,000,000) is greater than 2,147,483,647.

  6. {"-1 -2 5 7 -7 0","-1 -5 5 0 2 -3","10 -1 -1 -5 -2 1","0 9 7 1 -1 -1","-6 5 -7 4 10 8","6 0 -9 0 2 -4","8 1 -3 -5 3 -1"}

    {"-3"}

    {"1 -3 7","-8 8 -4","-7 7 0","7 2 0","1 3 0","8 -3 -8","6 -8 5","0 -8 3"}

    "B+C+C+B+A+C+C*B*A*A+B*B*B+A"

    Returns: { }

  7. {"4 -5 1 4","-5 -1 0 4","-9 7 -4 6","1 2 -8 -5"}

    {"-2 3 -5 -5","-3 1 8 -7","-5 -2 -9 0","2 0 9 7"}

    {"7 3 -3 -6","-8 -9 5 7","0 -7 8 8","0 -9 -7 -9"}

    "B+A"

    Returns: { "2 -2 -4 -1", "-8 0 8 -3", "-14 5 -13 6", "3 2 1 2" }

  8. {"2 0 -2 9","2 4 2 0","-8 1 4 10","-3 -7 5 6"}

    {"5 7 5 8","10 5 4 3","7 9 0 -7","-3 -3 -8 9"}

    {"-5 -1 3 -7","9 0 -9 8","2 6 6 2","3 -1 -7 -1"}

    "C*A+B+B+A+B+B+C+C*C*B*C"

    Returns: { "1919 -1738 -4819 -40", "-5529 3321 12923 939", "4138 -911 -8726 -1312", "-3812 1063 7580 815" }

    Keep in mind the order of operations.

  9. {"10 4 2","-6 4 -1","-6 -7 -7"}

    {"4 5 1","1 4 0","-8 -3 1"}

    {"-1 2 1","8 5 7","-2 1 -8"}

    "B*B+B+B+B+A*A*B+B+B+A+B+C+C+C*B+C*B+C*B"

    Returns: { "297 557 81", "-274 -191 -28", "-189 -48 14" }

  10. {"-9 3 -9","-2 -7 -4","5 7 3"}

    {"2 -5 10","8 10 8","4 -5 2"}

    {"-6 10 8","9 9 0","9 0 10"}

    "B*A*C*C+A*B*B*B*B*A*C"

    Returns: { "24563745 27253761 -9500296", "-13203354 -13853386 -19076880", "11298999 11598859 21610800" }

  11. {"0 -6 6","-9 -2 9","3 7 -9"}

    {"4 0 -5","2 -6 9","6 -3 2"}

    {"0 4 8","-4 10 0","2 7 3"}

    "C+C+B*C+A"

    Returns: { "-10 -17 39", "25 29 52", "23 29 51" }

  12. {"-7 -4 2 3 -7 8 10 -3 -9 -4","0 -1 -1 8 -3 1 9 0 1 -5","8 -4 4 6 -2 -2 -6 7 -7 -1","7 6 3 -1 4 3 4 -4 10 6","-9 5 10 0 -1 -1 7 -8 10 -1","5 -3 -9 -3 7 3 -6 3 10 10","0 9 1 9 10 -3 -5 4 -3 -4","-1 -4 1 0 2 0 -2 -7 1 -8","5 6 -4 6 6 9 -1 -8 -9 2","0 -1 10 -4 -1 -1 0 -1 5 -2"}

    {"2 10 -7 10 -2 -4 -6 -6 -2 0","-2 5 0 1 7 -9 6 -8 -5 -7","4 -6 0 4 0 6 0 -9 -7 0","5 4 -3 -4 -9 0 -1 7 8 -9","6 2 6 -7 10 3 7 -6 -7 7","0 1 3 -4 -4 8 4 -5 0 0","-3 -3 -6 -8 2 -3 0 -7 -6 -8","3 -4 -8 -5 7 8 10 -9 -7 6","-5 3 -1 -9 8 -7 1 9 8 -9","1 -2 -5 -1 1 -9 -2 9 0 6"}

    {"2 -7 -4 6 -6 0 10 -9 -6 -6","-9 -7 -4 -3 -4 3 5 -1 -5 0","7 -3 -6 2 -9 -8 6 7 -2 7","3 -9 -9 -5 0 4 9 8 -6 -8","-5 -1 0 -2 10 -2 1 -1 -7 -3","9 5 5 3 3 -3 10 -3 6 2","-1 9 2 0 0 -7 -3 2 -6 -7","0 -2 -9 -3 3 0 -2 9 3 -2","8 -7 -1 4 -6 -4 4 8 6 10","5 0 10 -3 2 9 -4 5 9 7"}

    "A*A*B*C+B+C+B*B*C+B"

    Returns: { "-51514 -19783 17168 -31417 46015 37217 -18017 7879 -35363 -28547", "-49114 -11103 -5936 -5123 -5096 -913 1796 -24864 -51370 -24483", "41888 2912 5911 5213 -1869 8964 9092 11099 43495 19702", "-836 10328 -502 23270 -34415 -18822 23539 -43124 -14452 -9694", "-37189 -39021 -553 -7920 -19797 42397 46301 -48179 -57771 -54218", "10568 7060 -28098 8201 -21495 -42582 -17734 30022 9998 38144", "-43913 9024 -42704 12159 -3745 -47753 -38476 -8526 -16743 4610", "-15826 -3231 3728 -12261 9644 18510 -21391 7280 -61 -5264", "-69333 52201 7751 -1922 57937 -39104 -97571 -9179 -9631 76", "39099 -22473 12570 2989 -23884 38629 52122 -11708 15743 -10743" }

  13. {"10 3 -2 0 8 -2 7 3 -5 -5","8 -6 0 -9 2 2 1 5 9 10","0 2 -2 3 -1 3 5 10 -7 8","9 0 6 -6 -1 -9 -9 6 -3 -8","0 -3 4 2 -2 0 4 -3 -9 -2","-5 5 -8 -8 0 -3 -4 10 6 -5","-6 10 3 -3 1 10 8 6 3 2","9 8 3 9 4 0 4 0 4 -8","-3 3 -7 10 8 -6 10 -8 8 -4","-8 -7 10 1 6 7 -3 7 -4 -2"}

    {"10 8 -7 0 -8 -1 -6 -1 -5 -9","6 -8 -4 0 -7 0 5 8 8 2","-5 -5 10 5 -2 -9 0 -3 7 9","-9 -9 -6 -5 -3 10 4 9 -8 -8","5 -2 5 9 -8 7 10 9 6 5","7 6 7 0 5 6 0 7 8 0","4 4 -2 -1 2 -1 -4 10 -7 -6","7 -9 4 4 -6 4 1 3 5 -2","1 -5 4 0 8 -1 -9 10 3 -7","-1 -3 2 0 9 2 0 9 -2 -3"}

    {"6 9 0 -8 5 -2 3 -2 0 8","-1 3 8 10 9 3 -3 7 0 -2","-8 2 -7 -9 -7 8 9 -4 -5 2","0 3 0 -4 -8 8 -5 -5 -2 8","2 6 0 -4 1 9 1 1 2 -4","-5 -4 -1 -4 -2 6 -1 -1 -2 -1","10 -3 6 -3 3 1 -6 8 -7 -1","6 -1 -5 0 6 6 4 4 -9 -1","-1 -8 -1 6 6 10 3 0 -3 1","2 2 0 -7 -3 0 10 -7 8 -8"}

    "A+B*B*C*A*C*C*C*C+A+C*A*C+B+A*C*B*C*C*B*C+B+B*C"

    Returns: { }

  14. {"2 -6 4 0 -6 -5 0 -5 -4 0","1 1 6 8 8 10 -6 6 8 10","-5 8 -1 6 9 0 7 9 4 10","0 4 -1 10 8 2 6 2 5 1","-2 4 -4 2 5 4 -6 -5 0 3","8 -9 0 0 8 -4 0 1 0 0","-3 1 7 2 9 -8 -5 -4 5 3","8 -1 10 0 -7 -4 0 -2 -8 0","-9 -6 -7 -5 -9 10 -9 -7 8 6","-6 9 5 7 8 4 3 2 -3 3"}

    {"-9 0 -5 0 -3 -4 -7 6 -3 0","8 8 0 -5 8 -6 5 0 -8 10","-2 5 -6 7 9 4 -3 2 -5 1","6 0 9 0 0 4 -8 -7 -9 9","0 8 -4 9 0 -3 -7 6 0 -9","10 -1 -9 -5 1 5 0 4 1 6","7 -1 -1 1 -8 6 7 10 4 -4","-6 6 8 10 2 0 9 0 10 -8","4 -5 -2 3 0 0 -9 0 2 10","-4 -6 -2 -2 -1 2 -4 8 6 5"}

    {"0 0 -6 -6 0 -1 1 10 2 4","9 3 8 7 4 1 -9 -2 -9 1","-3 4 -6 -6 -9 1 -9 -8 -4 -3","8 8 5 -5 -3 9 1 9 -8 -5","3 8 6 10 -9 5 5 1 3 4","-9 3 -7 -6 -8 3 -5 3 1 -3","5 7 -8 -4 9 -1 8 10 1 0","5 9 3 9 0 5 -2 -7 3 -9","8 -4 10 0 7 -5 -4 0 -1 0","-6 -8 -8 5 3 6 2 -1 5 10"}

    "B*C*B*B*A*B+B+B+A+C+A+B+A*A+C+C+A*A+C+C*B"

    Returns: { "-1338038 479018 -2251971 -8446367 2120517 -3897539 12222589 -4126275 710851 -1480307", "8090295 -5980209 -2925645 -12983914 -3523398 -40513 8154170 -3217571 2416210 3364977", "-16724241 -9095888 -9169700 -11841944 2942365 306852 2130956 -7098232 -6834913 1082614", "-29485798 -32956329 -8533398 -31618255 -21180423 347894 22653091 -17685587 3309435 -20036032", "-3243445 9064202 -2524237 11390714 15409856 -1545913 -16324659 2675542 -6554572 12305381", "12046201 5817857 3572289 -1746914 -4566330 1941570 9623180 3820385 686099 -4137203", "8108621 16304666 5167647 18410987 9228406 1116976 -11830948 8800602 -4705763 5657200", "3100890 12387720 581529 24431876 19552186 306179 -32934927 7783461 -5527800 21144542", "-1930426 -10725346 -753703 -14445426 -10617411 994667 15881884 -5120142 4860671 -8400970", "1265907 -1823782 -639290 -12200165 -3241227 -2394971 19032041 -4072713 2934844 -5139815" }

  15. {"-7 1 -6 -1 -8 6 6 0 10 9","4 -1 -3 1 10 10 -2 -8 -3 -7","0 -7 5 -2 2 -3 -5 10 10 9","4 -4 6 4 8 -4 -2 5 1 4","10 3 -7 6 10 -2 -8 -5 -7 -6","7 6 6 -8 -2 0 -5 3 5 3","6 10 10 -2 -3 0 9 8 9 6","7 -3 9 4 0 5 4 4 -8 1","-4 -1 0 -2 -3 -6 4 5 6 -8","0 -4 7 -1 7 10 8 7 3 5"}

    {"6 -5 -9 7 5 1 -2 -8 -5 7","-8 5 1 -6 2 9 7 1 -6 -4","2 2 0 3 -2 7 0 9 -1 4","1 5 2 8 -4 -8 7 2 -2 4","-9 8 5 -5 -5 -2 6 1 -5 -7","-9 0 -2 -1 -5 8 -4 -3 -6 8","6 -6 3 -7 -5 0 7 -5 4 3","9 -7 7 8 -5 0 0 10 2 6","3 5 2 1 -7 0 6 -6 7 5","3 6 0 -7 -5 -5 0 -8 6 -1"}

    {"-9 3 -8 1 1 6 -7 1 -6 0","-7 9 9 -4 6 6 0 -6 -2 10","5 4 5 -1 -9 10 5 2 -9 -8","-5 -3 10 0 -3 -9 -7 -7 3 5","-4 10 -1 -2 -9 -7 -6 0 -8 -5","2 -2 -7 0 -8 0 -7 5 -5 3","4 -5 6 -4 2 8 -8 -9 9 -8","0 6 -2 -6 1 7 -8 6 8 -6","6 -7 10 3 10 -9 2 -1 3 -5","-4 -6 8 5 2 -3 2 -8 9 -5"}

    "A+B+C*A*C*B+C"

    Returns: { "-16461 -28805 9653 -59876 43884 -16031 -35240 3553 1841 -57762", "-5254 -48156 7506 14713 63848 7460 -28136 61780 -28718 -36823", "-6887 6647 8281 11760 -45410 10289 26652 -1318 -14977 40047", "79451 -39356 -1109 60539 13311 -28714 20928 7589 25253 24005", "63143 -33772 -8464 -1477 30389 -66383 -20737 -26800 42472 -18240", "29896 -23799 -24443 25192 3945 -12775 -24007 -31811 14894 35133", "55795 30249 52697 -30981 -77839 -70992 96115 -35460 43349 -10324", "14714 -17036 14160 -39168 390 -40987 -5862 -27730 14350 -27782", "17625 46615 25637 3256 -28017 -28169 49669 11872 32741 -18863", "8827 16320 27426 -1519 -33006 10615 59311 15758 -1105 2331" }

  16. {"-4 5 -9","2 -7 8","4 -8 -5","10 6 -4"}

    {"7 -2 0 -3 -4","3 -5 6 6 1","-6 6 2 -3 -6"}

    {"2 -8 6 0 3","0 6 -6 0 0","6 4 8 -4 0","5 -9 -7 0 -6"}

    "A*B+C"

    Returns: { "43 -79 18 69 78", "-55 85 -32 -72 -63", "40 6 -50 -49 6", "117 -83 21 18 -16" }

  17. {"-4 -4 1","9 6 7","0 -1 10","-8 -9 -3"}

    {"7 4 9 8 -4","-4 -2 -6 1 0","1 -8 -2 -8 3"}

    {"-1 9 -5 7 -5","8 -3 9 4 -5","0 -3 -2 3 -3","3 -6 0 0 -7"}

    "A*B+C+A*B"

    Returns: { "-23 -23 -33 -81 33", "100 -67 71 48 -35", "28 -159 -30 -159 57", "-43 14 -24 -98 39" }

  18. {"-3 -1 0 3 0 7 6 -3","3 3 6 5 7 0 -1 3","-1 -7 -6 -9 -2 -2 -6 -5","-1 -4 -4 -3 -7 8 -8 0","9 2 -8 6 -8 2 -5 0","5 -3 7 -9 -6 0 0 8","0 1 -5 -1 -5 -4 4 -1","7 -3 -7 -3 6 4 -6 10","-6 -3 10 8 -6 6 -4 -5"}

    {"6 10 4 -2 -1 9 -7 -4 -8","0 4 -8 -3 -5 4 -2 -9 3","-5 10 -9 10 6 -7 8 -9 0","7 4 -2 10 3 -5 -4 -7 -3","2 0 -7 -8 -4 -1 -4 -7 4","0 -3 -7 -1 10 2 -1 10 5","-4 8 0 1 -1 -4 6 3 -5","4 -6 0 9 0 9 9 6 -2"}

    {"9 9 8 -8 -3 0 10 -6 -2","5 8 1 3 -4 -5 -7 1 -2","0 7 7 0 -1 -5 -9 -6 10","2 8 10 -8 -4 1 6 3 1","-9 -7 -3 -2 -5 -1 -3 -3 -8","-6 -7 5 5 8 9 7 -7 -9","7 -3 3 -1 -1 7 -8 8 0","3 -6 7 -9 -7 -3 -9 -5 -7","-8 -6 8 10 -5 10 10 -2 7"}

    "A*B*C*C+C"

    Returns: { "8809 -195 -17113 -6773 13078 -14670 1661 -1475 4906", "35847 -2510 24861 -22789 -20083 12037 -31842 16683 -35059", "-56927 -14647 -25668 33605 20932 14625 46848 5506 36340", "-34221 -18256 -48731 35096 64416 6010 -4409 6503 40129", "14909 45129 -41010 30229 14062 -23103 -40972 25802 37172", "-5747 13015 -12098 -10895 24043 -36697 -8050 -45676 -3021", "-7316 23345 -3273 7773 -11596 -19912 14944 -15966 16508", "-21566 -6744 -36684 23415 55672 18045 -19180 14972 14419", "33330 -7434 2221 -1761 1301 -12206 -34370 495 5126" }

  19. {"3 -9 0 -3 -9 -2 7 -4","-7 2 -8 0 4 7 -8 -6","3 0 0 7 -8 2 -3 2","-4 7 9 3 -2 -7 -9 10","0 -5 9 4 6 0 -6 10","5 1 3 9 -6 -9 10 7","-9 -9 1 -7 8 0 -8 -9","6 -2 9 -4 3 0 -6 -3","1 -8 3 7 0 9 -5 -6"}

    {"7 -8 0 6 -9 -6 2 -8 7","5 0 8 0 -1 -2 0 -9 4","0 -8 -5 5 -4 7 9 0 9","3 9 -8 7 -3 -5 -6 4 0","3 -3 -4 -8 6 -4 -9 5 -8","10 5 4 -7 -6 7 7 -6 0","5 4 6 -8 0 10 9 10 5","0 8 1 -8 3 9 -7 0 -5"}

    {"5 5 -3 7 5 -7 0 8 10","4 9 0 -5 -5 -2 10 6 -7","6 -3 -6 -1 0 3 0 7 5","4 -5 3 0 -8 -8 3 -8 2","5 0 0 0 4 -4 10 4 4","7 -8 -5 -7 4 7 -3 8 9","-8 -3 6 -9 -7 -5 4 7 2","9 6 7 6 -5 5 -4 5 0","-3 -6 -8 -2 -6 7 3 0 0"}

    "A*B*C*C+C+C*A*B+C"

    Returns: { "-15725 -23892 -15603 6204 6930 58270 -62942 -1872 1684", "7396 28801 19766 -10196 -12358 -56417 56056 6241 -17642", "-44744 -2481 7704 -8039 -2221 -5118 -12328 -24133 -23391", "-34711 -19238 -6043 -14986 25731 -26476 4337 -18596 6715", "19296 -2168 -17102 -1729 15898 -25420 25244 5940 13356", "2788 691 -3583 5368 -3003 15455 -28770 20442 17355", "17885 -14388 -20930 -11832 11882 -30059 27944 -7142 8938", "-55104 -56168 -24152 -5759 12727 17920 -21501 -82095 -20148", "-27249 -1614 -1434 -8518 -8183 -6582 -408 -31098 -31014" }

  20. {"-2 0 6 3 6 10 7 -5","-1 -2 1 2 8 -2 -2 1","8 6 3 -4 2 2 -8 3","8 1 -1 -9 6 0 -6 -3","3 8 -1 -5 9 -5 0 -9","4 -2 -8 5 -5 -2 0 2","-4 -9 0 9 4 4 -3 -4","-1 -4 2 6 8 -3 3 -2","2 -6 -9 8 -1 7 0 -4"}

    {"0 6 1 -1 -2 8 0 -3 0","9 -9 -1 0 6 0 2 0 9","3 7 -1 0 5 -8 -8 3 -6","-3 -3 -2 0 7 10 9 -3 6","-8 -7 -3 6 7 8 10 1 0","7 10 4 10 2 -7 6 -7 -9","-2 6 -3 -9 -1 5 0 10 8","-2 7 -7 -4 6 6 -5 -8 6"}

    {"-4 6 9 -9 -2 -3 10 -8 7","7 0 -2 4 6 2 3 8 -5","9 0 5 6 4 1 -9 -6 -6","2 0 -5 0 -4 -8 8 7 8","-4 7 6 5 0 -3 5 3 0","5 -6 5 10 7 2 -6 -3 0","-1 3 7 6 6 0 7 7 -9","-6 4 -3 -1 -7 0 8 7 -8","-3 -6 -5 0 -8 5 6 3 -9"}

    "A*B*C*C+C+C*B*A+C"

    Returns: { }

  21. {"10"}

    {"9"}

    {"-8"}

    "A*B*C*A*B*C*A*B*C"

    Returns: { "-373248000" }

  22. {"10"}

    {"9"}

    {"-8"}

    "A*B*C*A*B*C*A*B*C*A"

    Returns: { }

  23. {"-1"}

    {"2"}

    {"8"}

    "C*C*C*C*C*C*C*C*C*C+C*C*C*C*C*C*C*C*C*C"

    Returns: { }

  24. {"-1"}

    {"2"}

    {"8"}

    "C*C*C*C*C*C*C*C*C*C+A+C*C*C*C*C*C*C*C*C*C"

    Returns: { "2147483647" }

  25. {"-1"}

    {"2"}

    {"8"}

    "C*C*C*C*C*C*C*C*C*C*A+A*C*C*C*C*C*C*C*C*C*C"

    Returns: { "-2147483648" }

  26. {"-1"}

    {"2"}

    {"8"}

    "C*C*C*C*C*C*C*C*C*C*A+A*C*C*C*C*C*C*C*C*C*C+A"

    Returns: { }

  27. { "10 0", "0 0" }

    { "0" }

    { "0" }

    "A*A"

    Returns: { "100 0", "0 0" }

  28. { "1 1 1", "2 5 2", "3 5 -3" }

    { "1 1 1", "2 5 2", "3 5 -3" }

    { "1 1 1", "2 5 2", "3 5 -3" }

    "A+B+C+A+B+C*A+B+C+A+B+C*A+B+C+A*B+C*A+B+C+A+B+C+A"

    Returns: { "41 61 17", "106 233 58", "67 137 37" }

  29. { "1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1" }

    { "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1", "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1", "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1", "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1", "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1", "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1", "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1", "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1", "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1", "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1" }

    { "1 0 0 0 0 0 0 0 0 0", "0 1 0 0 0 0 0 0 0 0", "0 0 1 0 0 0 0 0 0 0", "0 0 0 1 0 0 0 0 0 0", "0 0 0 0 1 0 0 0 0 0", "0 0 0 0 0 1 0 0 0 0", "0 0 0 0 0 0 1 0 0 0", "0 0 0 0 0 0 0 1 0 0", "0 0 0 0 0 0 0 0 1 0", "0 0 0 0 0 0 0 0 0 1" }

    "A*A+A*B+A*C+B*B+B*C+B*A+C*C+C*A+C*B+A*B*C*B*A*A*B"

    Returns: { "-99999 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000", "-100000 -99999 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000", "-100000 -100000 -99999 -100000 -100000 -100000 -100000 -100000 -100000 -100000", "-100000 -100000 -100000 -99999 -100000 -100000 -100000 -100000 -100000 -100000", "-100000 -100000 -100000 -100000 -99999 -100000 -100000 -100000 -100000 -100000", "-100000 -100000 -100000 -100000 -100000 -99999 -100000 -100000 -100000 -100000", "-100000 -100000 -100000 -100000 -100000 -100000 -99999 -100000 -100000 -100000", "-100000 -100000 -100000 -100000 -100000 -100000 -100000 -99999 -100000 -100000", "-100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -99999 -100000", "-100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -99999" }

  30. { "4" }

    { "-2" }

    { "0" }

    "A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*B"

    Returns: { "-2147483648" }

  31. { "10 0", "0 0" }

    { "0" }

    { "0" }

    "A*A*A*A*A*A*A*A*A*A"

    Returns: { }

  32. { "4" }

    { "9" }

    { "1" }

    "B"

    Returns: { "9" }

  33. { "8" }

    { "8" }

    { "8" }

    "A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A"

    Returns: { }

  34. { "3 2", "1 2" }

    { "-1 2", "3 0" }

    { "1 -2", "-1 1" }

    "A+A+A*B+B*C+C*A+A*B*C+A*B"

    Returns: { "7 18", "16 -6" }

  35. { "2 2" }

    { "2", "-2" }

    { "10" }

    "C*C*C*C*C*C*C*C*C*A*B"

    Returns: { "0" }

  36. { "8" }

    { "-2" }

    { "1" }

    "B*A*A*A*A*A*A*A*A*A*A"

    Returns: { "-2147483648" }

  37. { "4" }

    { "4" }

    { "4" }

    "A"

    Returns: { "4" }

  38. { "2 -2", "3 -1", "5 2", "0 -1" }

    { "1 4 3", "-9 0 2" }

    { "2", "3", "-1" }

    "A*B*C+A*B*C"

    Returns: { "124", "106", "30", "40" }

  39. { "1 2 3", "5 6 7" }

    { "9 4", "1 4", "8 5" }

    { "9 4", "3 6" }

    "A*B*C"

    Returns: { "396 302", "1200 902" }

  40. { "10 10 10", "10 10 10", "10 10 10" }

    { "10 10 10", "10 10 10", "10 10 10" }

    { "1" }

    "A*B*A*B*A*A*A*A*A*A*A*A"

    Returns: { }

  41. { "1 1" }

    { "1 1", "1 1" }

    { "1" }

    "A*B"

    Returns: { "2 2" }

  42. { "10 10", "10 10" }

    { "10 10", "10 10" }

    { "10 10", "10 10" }

    "A*A*A*A*A*A*A*A*A*A*A"

    Returns: { }

  43. { "1" }

    { "2" }

    { "3" }

    "B"

    Returns: { "2" }

  44. { "-8 -8", "-8 -8" }

    { "2 2", "2 2" }

    { "0" }

    "A*A*A*A*A*A*A*B*B"

    Returns: { "-2147483648 -2147483648", "-2147483648 -2147483648" }

  45. { "2 4", "6 8" }

    { "1 1", "1 1" }

    { "0" }

    "A*A*A+B"

    Returns: { "297 433", "649 945" }

  46. { "8" }

    { "2" }

    { "-1" }

    "C*B*A*A*A*A*A*A*A*A*A*A"

    Returns: { "-2147483648" }

  47. { "-2" }

    { "8" }

    { "1" }

    "A*B*B*B*B*B*B*B*B*B*B"

    Returns: { "-2147483648" }

  48. { "8 0", "0 8" }

    { "-2 -2", "-2 -2" }

    { "9 0", "-8 0" }

    "A*A*A*A*A*A*A*A*A*A*B*C"

    Returns: { "-2147483648 0", "-2147483648 0" }

  49. { "8" }

    { "2" }

    { "-1" }

    "A*A*A*A*A*A*A*A*A*A*B*C"

    Returns: { }

  50. { "10 0", "0 0" }

    { "-10 0", "0 0" }

    { "1" }

    "A*A*A*A*A*A*A*A*A*A*A+B*A*A*A*A*A*A*A*A*A*A"

    Returns: { }

  51. { "-8" }

    { "8" }

    { "1" }

    "A*B*B*B*B*B*B*B*B*B*B*B*B*B"

    Returns: { }

  52. { "1 2", "3 4" }

    { "5 6", "7 8" }

    { "1" }

    "A*B+B*A"

    Returns: { "42 56", "74 96" }

  53. { "10" }

    { "10 10" }

    { "10", "-10" }

    "A*A*A*A*A*A*A*A*B*C"

    Returns: { "0" }

  54. { "10 10", "10 10" }

    { "10 10", "10 10" }

    { "1 1", "1 1" }

    "A*A*A*A*A*A*A*A*A*A*A*A+A*C"

    Returns: { }

  55. { "10 10" }

    { "10 0", "0 10" }

    { "10", "-10" }

    "A*B*B*B*B*B*B*B*B*C"

    Returns: { "0" }

  56. { "8" }

    { "8 8 8 8 8 -8 -8 -8 -8 -8" }

    { "8", "8", "8", "8", "8", "8", "8", "8", "8", "8" }

    "A*A*A*A*A*A*A*A*A*B*C"

    Returns: { "0" }

  57. { "1 2", "3 4" }

    { "2 3", "4 5" }

    { "3 4", "5 6" }

    "A*B+C*A"

    Returns: { "25 35", "45 63" }

  58. { "8" }

    { "-2" }

    { "0" }

    "A*A*A*A*A*A*A*A*A*A*B"

    Returns: { "-2147483648" }

  59. { "1 1" }

    { "10 0", "0 10" }

    { "10", "-10" }

    "A*B*B*B*B*B*B*B*B*B*C"

    Returns: { "0" }


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: