Advertisement
TwiNNeR

snzl6z3

Dec 11th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. import math
  2.  
  3.  
  4. def A1(s):
  5.     # print math.e
  6.     if s >= 60: return 1.0
  7.     return 1 / (math.pow(math.e, 60 - abs(s)))
  8.  
  9.  
  10. def A2(s):
  11.     if s <= 10: return 1.0
  12.     return 1 / (1 + math.pow(math.e, abs(10 - s)))
  13.  
  14.  
  15. def B1(s):
  16.     if s >= 0.8: return 1.0
  17.     return 1 / (1 + math.pow(0.2 + s, 3))
  18.  
  19.  
  20. def B2(s):
  21.     if 0 <= s <= 0.1: return 1.0
  22.     return 1 / (1 + math.pow(0.9 + s, 2))
  23.  
  24.  
  25. def C1(s):
  26.     return 2000
  27.  
  28.  
  29. def C2(s):
  30.     return 500
  31.  
  32.  
  33. def C3(s):
  34.     return 100
  35.  
  36.  
  37. def Rule1_min(s, e):
  38.     return min(A2(s), B2(e))
  39.  
  40.  
  41. def Rule2_min(s, e):
  42.     return min(A1(s), B2(e))
  43.  
  44.  
  45. def Rule3_min(s, e):
  46.     return min(A1(s), B1(e))
  47.  
  48.  
  49. def COG(w, c):
  50.     if len(w) != len(c):
  51.         return -1
  52.     else:
  53.         broitel = 0
  54.         imenitel = 0
  55.         for i in range(len(w)):
  56.             broitel += w[i] * c[i]
  57.             imenitel += w[i]
  58.         return broitel / imenitel
  59.  
  60.  
  61. if __name__ == "__main__":
  62.     t = input()
  63.     h = input()
  64.  
  65.     w = [Rule1_min(t, h), Rule2_min(t, h), Rule3_min(t, h)]
  66.     c = [C1(t), C2(t), C3(t)]
  67.  
  68.     cog = COG(w, c)
  69.     print cog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement