DamSi

Untitled

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