

'''simple docstring'''







import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey


class        A__   :



    def __init__(       self		,					UpperCamelCase__		,					UpperCamelCase__		,					UpperCamelCase__							)    ->   Tuple:





           '''simple docstring'''
           if dst_width < 0 or dst_height < 0:
                  raise ValueError("""Destination width/height should be > 0"""							)

           A_						       =   img
           A_						       =   img.shape[1]
           A_						       =   img.shape[0]
           A_						       =   dst_width
           A_						       =   dst_height

           A_						       =   self.src_w / self.dst_w
           A_						       =   self.src_h / self.dst_h

           A_						       =   A_						       =   (
               np.ones((self.dst_h, self.dst_w, 3)		,					np.uinta							) * 255
           )



    def        snake_case_      (       self							)    ->   Optional[Any]:





           '''simple docstring'''
           for i in range(self.dst_h							):
                  for j in range(self.dst_w							):
                         A_						       =   self.img[self.get_y(UpperCamelCase__							)][self.get_x(UpperCamelCase__							)]



    def        snake_case_      (       self		,					UpperCamelCase__							)    ->   int:





           '''simple docstring'''
           return int(self.ratio_x * x							)







    def        snake_case_      (       self		,					UpperCamelCase__							)    ->   int:





           '''simple docstring'''
           return int(self.ratio_y * y							)


if __name__ == "__main__":
      __lowerCamelCase							,   __lowerCamelCase									=     800, 600
      __lowerCamelCase									=     imread('''image_data/lena.jpg''', 1)
      __lowerCamelCase									=     NearestNeighbour(im, dst_w, dst_h)
      n.process()

      imshow(
          f"""Image resized from: {im.shape[1]}x{im.shape[0]} to {dst_w}x{dst_h}""", n.output
      )
      waitKey(0)
      destroyAllWindows()



'''simple docstring'''







from math import pow
def    UpperCAmelCase__     (   UpperCAmelCase__,							UpperCAmelCase__,							UpperCAmelCase__,							UpperCAmelCase__,							UpperCAmelCase__,							)      ->      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

       A_						       =   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
              A_       ,      A_						       =   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.
              A_       ,      A_						       =   backtrack(
                  UpperCAmelCase__,							UpperCAmelCase__,							current_number + 1,							UpperCAmelCase__,							UpperCAmelCase__					)
       return current_sum, solutions_count
def    UpperCAmelCase__     (   UpperCAmelCase__,							UpperCAmelCase__					)      ->      int:
       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()
