






'''simple docstring'''

from math import pow



def 							snake_case					(     a_							: int    ,   a_							: int    ,   a_							: int    ,   a_							: int    ,   a_							: int    ,   )       ->				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

      UpperCamelCase_				:   int					    =							int(pow(a_    ,   a_	)	)
      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_    ,			UpperCamelCase_				:   Optional[int]					    =							backtrack(
                a_    ,   a_    ,   current_number + 1    ,   a_    ,   a_	)
            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_    ,			UpperCamelCase_				:   Union[str, Any]					    =							backtrack(
                a_    ,   a_    ,   current_number + 1    ,   a_    ,   a_	)
      return current_sum, solutions_count



def 							snake_case					(     a_							: int    ,   a_							: int	)       ->				int:





      """simple docstring"""

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

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


if __name__ == "__main__":
      import doctest

      doctest.testmod()














'''simple docstring'''

# flake8: noqa
# Lint as: python3
UpperCamelCase							=[
    "VerificationMode",
    "Version",
    "disable_progress_bar",
    "enable_progress_bar",
    "is_progress_bar_enabled",
    "experimental",
]

from .info_utils import VerificationMode
from .logging import disable_progress_bar, enable_progress_bar, is_progress_bar_enabled
from .version import Version
from .experimental import experimental






