cswork / OA打开练习工作台

SnowflakeOA #27

Solve Matrix Equations (Also for AI/ML Interns :)

估计简单评测数据准备中,可先阅读题面

考点(AI 标注)位运算

Write a Python Program using SciPy that solves the equation X = A*B*C, given X, B, and C, as input. In the equation, X is a scalar, A is the unknown 1x2 vector, B is a 2x2 matrix, and C is a 2x1 vector. The two elements of A have the relationship A[1] = 1 - A[0]. Find the value of vector A. Function Description Complete the function findA in the editor below. findA has the following parameter(s):

  • float X: the value of X.
  • float B[2][2]: the matrix B.
  • float C[2][1]: the vector C. Returns float[2]: an array containing the two values A[0] and A[1].

Example 1

Input:

X = 0.35
B = [[3, -1], [-2, 3]]
C = [0.2, 0.8]

Output:

[0.75, 0.25]

Explanation: After solving the equation X = A*B*C under the constraints A[1] = 1 - A[0], the value of the vector A = [[0.75, 0.25]]. The values of A should be rounded to two decimal places.