Darkrai1337

Untitled

Dec 28th, 2021
1,134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1.  
  2. def input_polynom():
  3.     k = int(input("кол-во членов в многочлене: "))
  4.     mas = []
  5.     for i in range(k):
  6.         mas.append(int(input(f"a[{i}] = ")))
  7.     return mas
  8.  
  9. def multiply(a, b):
  10.  
  11.     c = [0.0]*(len(a) + len(b)-1)
  12.  
  13.     for i in range(len(a)):
  14.         for j in range(len(b)):
  15.             c[i + j] += a[i] * b[j]
  16.  
  17.     return c
  18.  
  19. def pow(a, n):
  20.  
  21.     c = [1]
  22.     for i in range(n):
  23.         c = multiply(c, a)
  24.     return c
  25.  
  26.  
  27. A = input_polynom()
  28. k = int(input("Степень: "))
  29. A.reverse()
  30. print(pow(A, k))
  31. input()
  32.  
  33.  
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment