想用 numpy 自带的解线性方程组搞这道题,然后发现提交会随机 RE,非常奇怪。
https://www.luogu.com.cn/record/52969303
https://www.luogu.com.cn/record/52970269
https://www.luogu.com.cn/record/52969766
这些提交都是同一份代码。
import numpy as np
import sys
sys.setrecursionlimit(1000000000)
n = int(input())
A = []
B = []
for i in range(n):
x = [int(i) for i in input().split()]
aa = x[:-1]
bb = x[-1]
A.append(aa)
B.append(bb)
a = np.array(A)
b = np.array(B)
try:
x = np.linalg.solve(a, b)
except:
print("No Solution")
else:
for i in range(len(x)):
print("%.2f" % (x[i]))