problem_two.py 551 B

12345678910111213141516171819202122232425262728
  1. numbers: dict[str, int] = {}
  2. char = ["a", "b", "c", "d", "e"]
  3. while char:
  4. try:
  5. num = int(input().strip())
  6. numbers[char.pop(0)] = num
  7. except EOFError:
  8. break
  9. def find_solutions(a: int, b: int, c: int, d: int, e: int) -> int:
  10. cnt = 0
  11. def equation(x: int) -> None:
  12. nonlocal cnt
  13. if x == e:
  14. return
  15. eq = a * (x**3) + b * (x**2) + c * x + d
  16. if eq == 0:
  17. cnt += 1
  18. for x in range(1001):
  19. equation(x)
  20. return cnt
  21. print(find_solutions(**numbers))