Matrix Power
2026/3/9小于 1 分钟
Matrix Power
题面
对 N×N 浮点矩阵 A 计算整数幂 P:输出 output = A^P(标准稠密矩阵乘,行优先存储)。
Implementation Requirements
- External libraries are not permitted.
- The solve function signature must remain unchanged.
- 结果写入
output(row-major)。
Examples
Example 1: A(2×2), P=3 → output=[[37,54],[81,118]]
Example 2: A(3×3), P=2 → 见页面矩阵与结果示例Constraints
- 1 ≤ N ≤ 1024;1 ≤ P ≤ 20
- -10.0 ≤ A_ij ≤ 10.0
- Performance: N = 512