Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = int(input())
- b = int(input())
- c = int(input())
- d = int(input())
- n1 = -1 * (a + b + c + d)
- n2 = a * (b + c + d) + b * (c + d) + c * d
- n3 = -1 * (a * b * c + a * b * d + a * c * d + b * c * d)
- n4 = a * b * c * d
- print("x^4 ", end="")
- if n1 != 0:
- if n1 == 1:
- print("+ x^3 ", end="")
- elif n1 == -1:
- print("- x^3 ", end="")
- else:
- if n1 > 0:
- print("+ " + str(n1) + "x^3 ", end="")
- else:
- print("- " + str(abs(n1)) + "x^3 ", end="")
- if n2 != 0:
- if n2 == 1:
- print("+ x^2 ", end="")
- elif n2 == -1:
- print("- x^2 ", end="")
- else:
- if n2 > 0:
- print("+ " + str(n2) + "x^2 ", end="")
- else:
- print("- " + str(abs(n2)) + "x^2 ", end="")
- if n3 != 0:
- if n3 == 1:
- print("+ x ", end="")
- elif n3 == -1:
- print("- x ", end="")
- else:
- if n3 > 0:
- print("+ " + str(n3) + "x ", end="")
- else:
- print("- " + str(abs(n3)) + "x ", end="")
- if n4 != 0:
- if n4 > 0:
- print("+ " + str(n4))
- else:
- print("- " + str(abs(n4)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement