






from math import pow

def _UpperCAmelCase (						a    :						int	,       a    :						int	,       a    :						int	,       a    :						int	,       a    :						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

							snake_case__							=							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
														snake_case__							=							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.
														snake_case__							=							backtrack(
														    __lowerCamelCase	,       __lowerCamelCase	,       current_number + 1	,       __lowerCamelCase	,       __lowerCamelCase			)
							return current_sum, solutions_count

def _UpperCAmelCase (						a    :						int	,       a    :						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(__lowerCamelCase	,       __lowerCamelCase	,       1	,       0	,       0			)[1]  # Return the solutions_count


if __name__ == "__main__":
	import doctest

	doctest.testmod()




'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase				={
    'configuration_table_transformer': [
        'TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'TableTransformerConfig',
        'TableTransformerOnnxConfig',
    ]
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowercase				=[
     'TABLE_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
     'TableTransformerForObjectDetection',
     'TableTransformerModel',
     'TableTransformerPreTrainedModel',
 ]


if TYPE_CHECKING:
 from .configuration_table_transformer import (
     TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
     TableTransformerConfig,
     TableTransformerOnnxConfig,
 )

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_table_transformer import (
      TABLE_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
      TableTransformerForObjectDetection,
      TableTransformerModel,
      TableTransformerPreTrainedModel,
  )

else:
 import sys

 lowercase				=_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

