fork(13) download
  1. a = float(raw_input())
  2. b = float(raw_input())
  3.  
  4. l = 0
  5. p = 10
  6.  
  7. x1 = a*0 + b
  8. x2 = a*10 + b
  9.  
  10. tmp = x1 * x2
  11.  
  12. X = (p - l)/2
  13.  
  14. if tmp <=0:
  15. while abs(a*X + b) > 0.001:
  16. if((a*X+b)*(a*l+b) <= 0):
  17. p = X
  18. elif ((a*X+b)*(a*p+b) <= 0):
  19. l = X
  20. X = (p - l) / 2
  21. print X
  22. else:
  23. print "BRAK"
Success #stdin #stdout 0.01s 7856KB
stdin
1
-2
stdout
2