




import timeit







class 		__UpperCAmelCase:





     """simple docstring"""



     def __init__(   self			:							List[str]    ,					A			:							int     )      ->      Dict:






         """simple docstring"""
         if isinstance(A    ,					A     ):  # Initializes a matrix identical to the one provided.
             a__  			=							arg
             a__  			=							len(A     )
         else:  # Initializes a square matrix of the given size and set values to zero.
             a__  			=							arg
             a__  			=							[[0 for _ in range(self.n     )] for _ in range(self.n     )]






     def __mul__(   self			:							Dict    ,					A			:							Dict     )      ->      Optional[Any]:






         """simple docstring"""
         a__  			=							Matrix(self.n     )
         for i in range(self.n     ):
             for j in range(self.n     ):
                 for k in range(self.n     ):
                     matrix.t[i][j] += self.t[i][k] * b.t[k][j]
         return matrix






def 							__lowerCAmelCase			(UpperCAmelCase_ ,     UpperCAmelCase_		):
    a__  			=							Matrix([[1, 0], [0, 1]]		)
    while b > 0:
        if b & 1:
            matrix *= a
        a *= a
        b >>= 1
    return matrix
def 							__lowerCAmelCase			(UpperCAmelCase_ ,     UpperCAmelCase_ ,     UpperCAmelCase_		):
    # Trivial Cases
    if n == 1:
        return fa
    elif n == 2:
        return fa
    a__  			=							Matrix([[1, 1], [1, 0]]		)
    a__  			=							modular_exponentiation(UpperCAmelCase_ ,     n - 2		)
    return fa * matrix.t[0][0] + fa * matrix.t[0][1]
def 							__lowerCAmelCase			(UpperCAmelCase_ ,     UpperCAmelCase_ ,     UpperCAmelCase_		):
    # Trivial Cases
    if n == 1:
        return fa
    elif n == 2:
        return fa

    a__  			=							fa
    a__  			=							fa
    n -= 2

    while n > 0:
        a__			,		a__  			=							fn_a + fn_a, fn_a
        n -= 1

    return fn_a
def 							__lowerCAmelCase			():
    a__  			=							"""
from random import randint
from __main__ import fibonacci_with_matrix_exponentiation
"""
    a__  			=							"""fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)"""
    a__  			=							timeit.timeit(setup=UpperCAmelCase_ ,     stmt=UpperCAmelCase_ ,     number=100		)
    print("""With matrix exponentiation the average execution time is """ ,     exec_time / 100		)
    return exec_time
def 							__lowerCAmelCase			():
    a__  			=							"""
from random import randint
from __main__ import simple_fibonacci
"""
    a__  			=							"""simple_fibonacci(randint(1,70000), 1, 1)"""
    a__  			=							timeit.timeit(setup=UpperCAmelCase_ ,     stmt=UpperCAmelCase_ ,     number=100		)
    print(
        """Without matrix exponentiation the average execution time is """ ,     exec_time / 100		)
    return exec_time
def 							__lowerCAmelCase			():
    matrix_exponentiation_time()
    simple_fibonacci_time()


if __name__ == "__main__":
 main()












from __future__ import annotations

import random







class 		__UpperCAmelCase:





     """simple docstring"""



     __UpperCAmelCase						:			Optional[int]							=     6

     def __init__(   self			:							int     )      ->      Optional[Any]:






         """simple docstring"""
         a__  			=							list(range(1    ,					Dice.NUM_SIDES + 1     )     )






     def 					__SCREAMING_SNAKE_CASE		(   self			:							Union[str, Any]     )      ->      List[str]:






         """simple docstring"""
         return random.choice(self.sides     )






def 							__lowerCAmelCase			(UpperCAmelCase_ ,     UpperCAmelCase_ = 2		):
    a__  			=							[Dice() for i in range(UpperCAmelCase_		)]
    a__  			=							[0] * (len(UpperCAmelCase_		) * Dice.NUM_SIDES + 1)
    for _ in range(UpperCAmelCase_		):
        count_of_sum[sum(dice.roll() for dice in dices		)] += 1
    a__  			=							[round((count * 100) / num_throws ,     2		) for count in count_of_sum]
    return probability[num_dice:]  # remove probability of sums that never appear


if __name__ == "__main__":
 import doctest

 doctest.testmod()






