
"""simple docstring"""







from math import pow
def   __UpperCamelCase   (					SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    )  ->     tuple[int, int]:







							"""simple docstring"""


							if current_sum == needed_sum:
														# If the sum of the powers is equal to needed_sum, then we have a solution.
														solutions_count += 1
														return current_sum, solutions_count

							__snake_case     			=       int(pow(SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE ) )
							if current_sum + i_to_n <= needed_sum:
														# If the sum of the powers is less than needed_sum, then continue adding powers.
														current_sum += i_to_n
														__snake_case			,   __snake_case     			=       backtrack(
														    SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    current_number + 1							,    SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE )
														current_sum -= i_to_n
							if i_to_n < needed_sum:
														# If the power of i is less than needed_sum, then try with the next power.
														__snake_case			,   __snake_case     			=       backtrack(
														    SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    current_number + 1							,    SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE )
							return current_sum, solutions_count
def   __UpperCamelCase   (					SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE )  ->     int:







							"""simple docstring"""


							if not (1 <= needed_sum <= 10_00 and 2 <= power <= 10):
														raise ValueError(
														    "Invalid input\n"
														    "needed_sum must be between 1 and 1000, power between 2 and 10." )

							return backtrack(SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    1							,    0							,    0 )[1]  # Return the solutions_count


if __name__ == "__main__":
		import doctest

		doctest.testmod()


"""simple docstring"""







from __future__ import annotations

from typing import Any
def   __UpperCamelCase   (					SCREAMING_SNAKE_CASE )  ->     int:







							"""simple docstring"""


							if not postfix_notation:
														return 0

							__snake_case     			=       {"+", "-", "*", "/"}
							__snake_case     			=       []

							for token in postfix_notation:
														if token in operations:
																					__snake_case			,   __snake_case     			=       stack.pop(), stack.pop()
																					if token == "+":
																												stack.append(a + b )
																					elif token == "-":
																												stack.append(a - b )
																					elif token == "*":
																												stack.append(a * b )
																					else:
																												if a * b < 0 and a % b != 0:
																																			stack.append(a // b + 1 )
																												else:
																																			stack.append(a // b )
														else:
																					stack.append(int(SCREAMING_SNAKE_CASE ) )

							return stack.pop()


if __name__ == "__main__":
		import doctest

		doctest.testmod()
