





from math import pow



def 	A_       (  _lowerCAmelCase							,     _lowerCAmelCase							,     _lowerCAmelCase							,     _lowerCAmelCase							,     _lowerCAmelCase							,     )		->				tuple[int, int]:
 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			:      Dict 			=     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			:      Union[str, Any] 			=     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			:      Any 			=     backtrack(
      UpperCamelCase__							,     UpperCamelCase__							,     current_number + 1							,     UpperCamelCase__							,     UpperCamelCase__  )
 return current_sum, solutions_count



def 	A_       (  _lowerCAmelCase							,     _lowerCAmelCase  )		->				int:
 if not (1 <= needed_sum <= 1000 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()








from ..utils import DummyObject, requires_backends



class       A__     ( metaclass=__snake_case    ):
      _UpperCAmelCase			:Tuple							=     ['note_seq']





      def __init__(				self ,							*A_ ,							**A_     ):
       '''simple docstring'''




       requires_backends(self ,							["note_seq"]     )





      @classmethod
      def  __UpperCamelCase(				cls ,							*A_ ,							**A_     ):
       '''simple docstring'''




       requires_backends(cls ,							["note_seq"]     )





      @classmethod
      def  __UpperCamelCase(				cls ,							*A_ ,							**A_     ):
       '''simple docstring'''




       requires_backends(cls ,							["note_seq"]     )
