1. Link to the question: CCF 201903-2 Twenty-Four Points
Question No.: | 201903-2 |
---|---|
Question name: | blackjack |
time limit: | 1.0s |
Memory limit: | 512.0MB |
Problem Description: | |
2. Problem analysis:
After reading the question analysis, this question directly uses the Python language built-in string expression to execute the function eval to quickly AC, just put the lowercase letter xxreplace x with ∗ *∗, / / / replace with////// , because in the Python language//The / operator represents floating-point division, while// //// The operator represents integer division, which is equivalent to/// operator.
3. Python language program implementation:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
@Time : 2022/6/8 08:23
@Author : Albert Darren
@Contact : [email protected]
@File : 201903-2.py
@Version : Version 1.0.0
@Description : TODO
@Created By : PyCharm
"""
n = int(input())
expressions = []
for i in range(n):
expr = input()
expr = expr.replace("x", "*")
expr = expr.replace("/", "//")
if eval(expr) == 24:
expressions.append("Yes")
else:
expressions.append("No")
for e in expressions:
print(e)