

'''simple docstring'''
from __future__ import annotations

from scipy.special import comb  # type: ignore







class 							A__   :





  def __init__(		self				:     Any							, _a				:     list[tuple[float, float]]			)     ->   Dict:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							   =list_of_points
       # Degree determines the flexibility of the curve.
       # Degree = 1 will produce a straight line.
       _SCREAMING_SNAKE_CASE							   =len(_a			) - 1





  def 						A  (		self				:     Optional[int]							, _a				:     float			)     ->   list[float]:





       '''simple docstring'''






       assert 0 <= t <= 1, "Time t must be between 0 and 1."
       _SCREAMING_SNAKE_CASE							   =[]
       for i in range(len(self.list_of_points			)			):
            # basis function for each i
            output_values.append(
                comb(self.degree							, _a			) * ((1 - t) ** (self.degree - i)) * (t**i)			)
       # the basis must sum up to 1 for it to produce a valid Bezier curve.
       assert round(sum(_a			)							, 5			) == 1
       return output_values





  def 						A  (		self				:     Union[str, Any]							, _a				:     float			)     ->   tuple[float, float]:





       '''simple docstring'''






       assert 0 <= t <= 1, "Time t must be between 0 and 1."

       _SCREAMING_SNAKE_CASE							   =self.basis_function(_a			)
       _SCREAMING_SNAKE_CASE							   =0.0
       _SCREAMING_SNAKE_CASE							   =0.0
       for i in range(len(self.list_of_points			)			):
            # For all points, sum up the product of i-th basis function and i-th point.
            x += basis_function[i] * self.list_of_points[i][0]
            y += basis_function[i] * self.list_of_points[i][1]
       return (x, y)





  def 						A  (		self				:     Any							, _a				:     float = 0.01			)     ->   List[str]:





       '''simple docstring'''






       from matplotlib import pyplot as plt  # type: ignore

       _SCREAMING_SNAKE_CASE							   =[]  # x coordinates of points to plot
       _SCREAMING_SNAKE_CASE							   =[]  # y coordinates of points to plot

       _SCREAMING_SNAKE_CASE							   =0.0
       while t <= 1:
            _SCREAMING_SNAKE_CASE							   =self.bezier_curve_function(_a			)
            to_plot_x.append(value[0]			)
            to_plot_y.append(value[1]			)
            t += step_size

       _SCREAMING_SNAKE_CASE							   =[i[0] for i in self.list_of_points]
       _SCREAMING_SNAKE_CASE							   =[i[1] for i in self.list_of_points]

       plt.plot(
           _a							, _a							, color='blue'							, label='Curve of Degree ' + str(self.degree			)							, )
       plt.scatter(_a							, _a							, color='red'							, label='Control Points'			)
       plt.legend()
       plt.show()


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     BezierCurve([(1, 2), (3, 5)]).plot_curve()  # degree 1
     BezierCurve([(0, 0), (5, 5), (5, 0)]).plot_curve()  # degree 2
     BezierCurve([(0, 0), (5, 5), (5, 0), (2.5, -2.5)]).plot_curve()  # degree 3



'''simple docstring'''
from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt


def 	_lowerCAmelCase (						_UpperCamelCase						:					int    )				->      bool:
     """simple docstring"""




     _SCREAMING_SNAKE_CASE							   =int(number**0.5    )
     return number == sq * sq


def 	_lowerCAmelCase (						_UpperCamelCase						:					int							,			_UpperCamelCase						:					int							,			_UpperCamelCase						:					int							,			_UpperCamelCase						:					int							,			_UpperCamelCase						:					int							,			_UpperCamelCase						:					int    )				->      tuple[int, int]:
     """simple docstring"""




     _SCREAMING_SNAKE_CASE							   =x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
     _SCREAMING_SNAKE_CASE							   =x_den * y_den * z_den
     _SCREAMING_SNAKE_CASE							   =gcd(_UpperCamelCase							,			_UpperCamelCase    )
     top //= hcf
     bottom //= hcf
     return top, bottom


def 	_lowerCAmelCase (						_UpperCamelCase						:					int = 35    )				->      int:
     """simple docstring"""




     _SCREAMING_SNAKE_CASE							   =set()
     _SCREAMING_SNAKE_CASE							   =42
     _SCREAMING_SNAKE_CASE							   =Fraction(0    )
     _SCREAMING_SNAKE_CASE							   =42

     for x_num in range(1							,			order + 1    ):
          for x_den in range(x_num + 1							,			order + 1    ):
               for y_num in range(1							,			order + 1    ):
                    for y_den in range(y_num + 1							,			order + 1    ):
                         # n=1
                         _SCREAMING_SNAKE_CASE							   =x_num * y_den + x_den * y_num
                         _SCREAMING_SNAKE_CASE							   =x_den * y_den
                         _SCREAMING_SNAKE_CASE							   =gcd(_UpperCamelCase							,			_UpperCamelCase    )
                         z_num //= hcf
                         z_den //= hcf
                         if 0 < z_num < z_den <= order:
                              _SCREAMING_SNAKE_CASE							   =add_three(
                                  _UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase    )
                              unique_s.add(_UpperCamelCase    )

                         # n=2
                         _SCREAMING_SNAKE_CASE							   =(
                             x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
                         )
                         _SCREAMING_SNAKE_CASE							   =x_den * x_den * y_den * y_den
                         if is_sq(_UpperCamelCase    ) and is_sq(_UpperCamelCase    ):
                              _SCREAMING_SNAKE_CASE							   =int(sqrt(_UpperCamelCase    )    )
                              _SCREAMING_SNAKE_CASE							   =int(sqrt(_UpperCamelCase    )    )
                              _SCREAMING_SNAKE_CASE							   =gcd(_UpperCamelCase							,			_UpperCamelCase    )
                              z_num //= hcf
                              z_den //= hcf
                              if 0 < z_num < z_den <= order:
                                   _SCREAMING_SNAKE_CASE							   =add_three(
                                       _UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase    )
                                   unique_s.add(_UpperCamelCase    )

                    # n=-1
                         _SCREAMING_SNAKE_CASE							   =x_num * y_num
                         _SCREAMING_SNAKE_CASE							   =x_den * y_num + x_num * y_den
                         _SCREAMING_SNAKE_CASE							   =gcd(_UpperCamelCase							,			_UpperCamelCase    )
                         z_num //= hcf
                         z_den //= hcf
                         if 0 < z_num < z_den <= order:
                              _SCREAMING_SNAKE_CASE							   =add_three(
                                  _UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase    )
                              unique_s.add(_UpperCamelCase    )

                         # n=2
                         _SCREAMING_SNAKE_CASE							   =x_num * x_num * y_num * y_num
                         _SCREAMING_SNAKE_CASE							   =(
                             x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
                         )
                         if is_sq(_UpperCamelCase    ) and is_sq(_UpperCamelCase    ):
                              _SCREAMING_SNAKE_CASE							   =int(sqrt(_UpperCamelCase    )    )
                              _SCREAMING_SNAKE_CASE							   =int(sqrt(_UpperCamelCase    )    )
                              _SCREAMING_SNAKE_CASE							   =gcd(_UpperCamelCase							,			_UpperCamelCase    )
                              z_num //= hcf
                              z_den //= hcf
                              if 0 < z_num < z_den <= order:
                                   _SCREAMING_SNAKE_CASE							   =add_three(
                                       _UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase							,			_UpperCamelCase    )
                                   unique_s.add(_UpperCamelCase    )

     for num, den in unique_s:
          total += Fraction(_UpperCamelCase							,			_UpperCamelCase    )

     return total.denominator + total.numerator


if __name__ == "__main__":
     print(f'''{solution() = }''')
