
"""simple docstring"""


from math import pow



def 						lowerCamelCase__      (				UpperCAmelCase_		,   UpperCAmelCase_		,   UpperCAmelCase_		,   UpperCAmelCase_		,   UpperCAmelCase_		,   )->				Union[str, Any]:







       """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

       UpperCamelCase       			=		int(pow(UpperCAmelCase_		,   UpperCAmelCase_					)					)
       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
              UpperCamelCase       			=		backtrack(
                  UpperCAmelCase_		,   UpperCAmelCase_		,   current_number + 1		,   UpperCAmelCase_		,   UpperCAmelCase_					)
              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.
              UpperCamelCase       			=		backtrack(
                  UpperCAmelCase_		,   UpperCAmelCase_		,   current_number + 1		,   UpperCAmelCase_		,   UpperCAmelCase_					)
       return current_sum, solutions_count



def 						lowerCamelCase__      (				UpperCAmelCase_		,   UpperCAmelCase_					)->				List[Any]:







       """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(UpperCAmelCase_		,   UpperCAmelCase_		,   1		,   0		,   0					)[1]  # Return the solutions_count


if __name__ == "__main__":
      import doctest

      doctest.testmod()










'''simple docstring'''



def        UpperCAmelCase (    A	:					int       ,		A	:					int					):
							return x if y == 0 else greatest_common_divisor(A       ,		x % y					)
def        UpperCAmelCase (    A	:					int       ,		A	:					int					):
							return (x * y) // greatest_common_divisor(A       ,		A					)
def        UpperCAmelCase (    A	:					int = 20					):
							SCREAMING_SNAKE_CASE       :   Tuple         =      1
							for i in range(1       ,		n + 1					):
														SCREAMING_SNAKE_CASE       :   Optional[int]         =      lcm(A       ,		A					)
							return g


if __name__ == "__main__":
							print(f'{solution() = }')




