P10372: Duplicate of P1981?

· · 题解

以下思路由 andyli 提供。

通过 da32s1da 的 P1981 题解,我们看到了 Python 的威力。

现在我们再用一次:让 Python 自行根据形如 a+b==c 的布尔运算求解!

AC Code:

for _ in range(int(input())):                  # T 组数据
    s = input().replace('=', '==')             # 把 a+b=c 改为 a+b==c 
    print(eval(s) and 'Right!' or 'Wrong!')    # 利用 eval 函数让 Python 进行布尔运算求解