Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. lis = [float(x) for x in input().split()]
  2. target = float(input())
  3.  
  4. def binary(lis,target):
  5. lo = 0;
  6. hi = 100
  7. m = ( lo + hi ) /2.0
  8. while hi-lo>0.000001:
  9.  
  10. m = (lo+hi)/2.0
  11.  
  12. total = calculate(lis+[m])
  13.  
  14. if total <= target+0.00001:
  15. lo = m
  16. else:
  17. hi = m
  18. return m
  19.  
  20. def calculate(lis):
  21. #print(lis)
  22. return sum(sorted(lis)[1:4])/3.0
  23.  
  24.  
  25. result = binary(lis,target)
  26.  
  27. if result <= 0.9:
  28. print("impossible")
  29. elif result >= 30:
  30. print("infinite")
  31. else:
  32. print("%.2f" % result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement