9.9 360笔试修复方程 困惑
有大佬看一看修复方程这道题为什么错了么,只过了9%
def check(s1, s2):
for i in range(10):
for pos in range(len(s1) + 1):
if (pos == 0 and i == 0)&nbs***bsp;(i == 0 and not ('0' <= s1[pos - 1] <= '9')):
continue
tmp = s1[:pos] + str(i) + s1[pos:]
if eval(tmp) == eval(s2):
return True
return False
T = int(input())
for _ in range(T):
s = input()
s = s.replace(' ', '')
left, right = s.split('=')
if eval(left) == eval(right):
print("Yes")
else:
if check(left, right)&nbs***bsp;check(right, left):
print("Yes")
else:
print("No")