Advertisement
n_o_m_a_d

predict.py

Jun 20th, 2013
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. #!/bin/python
  2.  
  3. import time
  4.  
  5. t1 = time.clock()
  6.  
  7. f = open("testing/test_cases.txt","r")
  8. o = open("testing/Pyoutput.txt","w")
  9.  
  10. cases = int(f.readline())
  11.  
  12. while cases > 0:
  13.     cases -= 1
  14.     gain = 0.0
  15.     p = float(f.readline())
  16.     if p >= .5:
  17.         gain = 10000 * (1-p) * (2*p-1)
  18.     else:
  19.         gain = p * 10000 * (1-2*p)
  20.     o.write(str(gain+10000)+"\n")
  21.  
  22. f.close()
  23. o.close()
  24.  
  25. t2 = time.clock()
  26.  
  27. print "Took ",t2-t1," seconds"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement