from itertools import permutations, product
from operator import add, sub, mul
import math
def div(a,b):
return a/b if b else float('inf')
operators = [add, sub, mul, div]
a = list(map(int,input().split()))
a_perms = set(permutations(a))
op_prod = list(product(operators,repeat=3))
flag=False
for a1,a2,a3,a4 in a_perms:
for f1,f2,f3 in op_prod:
if math.isclose(f1(a1,f2(a2,f3(a3,a4))),24) or\
math.isclose(f1(f2(a1,a2),f3(a3,a4)),24):
flag = True
if flag:
print("true")
else:
print('false')
优雅的枚举


京公网安备 11010502036488号