Advertisement
dmemsm

Задача 9

Jan 12th, 2025
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. a = int(input())
  2. b = int(input())
  3. c = int(input())
  4. d = int(input())
  5.  
  6. n1 = -1 * (a + b + c + d)
  7. n2 = a * (b + c + d) + b * (c + d) + c * d
  8. n3 = -1 * (a * b * c + a * b * d + a * c * d + b * c * d)
  9. n4 = a * b * c * d
  10.  
  11. print("x^4 ", end="")
  12.  
  13. if n1 != 0:
  14.     if n1 == 1:
  15.         print("+ x^3 ", end="")
  16.     elif n1 == -1:
  17.         print("- x^3 ", end="")
  18.     else:
  19.         if n1 > 0:
  20.             print("+ " + str(n1) + "x^3 ", end="")
  21.         else:
  22.             print("- " + str(abs(n1)) + "x^3 ", end="")
  23.  
  24. if n2 != 0:
  25.     if n2 == 1:
  26.         print("+ x^2 ", end="")
  27.     elif n2 == -1:
  28.         print("- x^2 ", end="")
  29.     else:
  30.         if n2 > 0:
  31.             print("+ " + str(n2) + "x^2 ", end="")
  32.         else:
  33.             print("- " + str(abs(n2)) + "x^2 ", end="")
  34.  
  35. if n3 != 0:
  36.     if n3 == 1:
  37.         print("+ x ", end="")
  38.     elif n3 == -1:
  39.         print("- x ", end="")
  40.     else:
  41.         if n3 > 0:
  42.             print("+ " + str(n3) + "x ", end="")
  43.         else:
  44.             print("- " + str(abs(n3)) + "x ", end="")
  45.  
  46. if n4 != 0:
  47.     if n4 > 0:
  48.         print("+ " + str(n4))
  49.     else:
  50.         print("- " + str(abs(n4)))
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement