Ответсообщение недоступно
def sorting(symbols, nums, operations):
for k in symbols:
try:
if str(abs(int(k))).isdigit() is True:
nums.append(int(k))
except ValueError:
break
for jj in nums:
symbols.pop(symbols.index(str(jj)))
for i in symbols:
if i.isdigit() is False:
operations.append(i)
else:
break
for df in operations:
symbols.pop(symbols.index(str(df)))
return nums, operations, symbols
def main_process(nums, operations):
for opera in operations:
if opera == '#':
nums.append(nums[len(nums) - 1])
elif opera == '*':
nums.append(nums[len(nums) - 2] * nums[len(nums) - 1])
nums.pop(len(nums) - 2)
nums.pop(len(nums) - 2)
elif opera == '-':
nums.append(nums[len(nums) - 2] - nums[len(nums) - 1])
nums.pop(len(nums) - 3)
nums.pop(len(nums) - 2)
elif opera == '+':
nums.append(nums[len(nums) - 2] + nums[len(nums) - 1])
nums.pop(len(nums) - 3)
nums.pop(len(nums) - 2)
elif opera == '/':
nums.append(nums[len(nums) - 2] // nums[len(nums) - 1])
nums.pop(len(nums) - 3)
nums.pop(len(nums) - 2)
elif opera == '~':
nums.append(-1 * nums[len(nums) - 1])
nums.pop(len(nums) - 2)
elif opera == '!':
nums.append(fact(nums[len(nums) - 1]))
nums.pop(len(nums) - 2)
elif opera == '@':
nums.append(nums[len(nums) - 2])
nums.append(nums[len(nums) - 2])
nums.append(nums[len(nums) - 5])
nums.pop(len(nums) - 4)
nums.pop(len(nums) - 4)
nums.pop(len(nums) - 4)
return nums[0]
def fact(x):
mmm = 1
for m in range(2, x + 1):
mmm *= m
return mmm
symbolsx, numsx, operationsx, move = str(input()).split(' '), [], [], -1
while len(symbolsx) != 1:
sorting(symbolsx, numsx, operationsx)
symbolsx.insert(0, str(main_process(numsx, operationsx)))
numsx, operationsx = [], []
print(symbolsx[0])