





from math import pow





def     _UpperCamelCase     (a__   :int   ,			a__   :int   ,			a__   :int   ,			a__   :int   ,			a__   :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(pow(_lowerCamelCase   ,			_lowerCamelCase       )       )
							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(
														    _lowerCamelCase   ,			_lowerCamelCase   ,			current_number + 1   ,			_lowerCamelCase   ,			_lowerCamelCase       )
														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(
														    _lowerCamelCase   ,			_lowerCamelCase   ,			current_number + 1   ,			_lowerCamelCase   ,			_lowerCamelCase       )
							return current_sum, solutions_count





def     _UpperCamelCase     (a__   :int   ,			a__   :int       ):






							"""simple docstring"""





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


if __name__ == "__main__":
					import doctest

					doctest.testmod()









import inspect
import unittest

class        __SCREAMING_SNAKE_CASE					(     unittest.TestCase       ):






							def 				_lowerCamelCase		(						self  ):
														try:
																					import diffusers  # noqa: F401
														except ImportError:
																					assert False







							def 				_lowerCamelCase		(						self  ):
														import diffusers
														from diffusers.dependency_versions_table import deps

														UpperCamelCase__				     =			inspect.getmembers(__lowerCAmelCase  , inspect.isclass  )

														for cls_name, cls_module in all_classes:
																					if "dummy_" in cls_module.__module__:
																												for backend in cls_module._backends:
																																			if backend == "k_diffusion":
																																										UpperCamelCase__				     =			"""k-diffusion"""
																																			elif backend == "invisible_watermark":
																																										UpperCamelCase__				     =			"""invisible-watermark"""
																																			assert backend in deps, f"""{backend} is not in the deps table!"""




