fork download
  1.  
  2. from __future__ import division
  3.  
  4. saved = {}
  5. t = input()
  6.  
  7. def func(f):
  8. if f in saved: return saved[f]
  9. x,y,z,n = f
  10. if z >= n: return 1
  11. if x == 120: return 0
  12. if y == 10: return 0
  13.  
  14. saved[f] = (func((x+1,y+1,z,n)) + func((x+1, y,z,n)) + func((x+1,y,z+1,n)) + func((x+1, y, z+2,n)) + func((x+1, y, z+3,n)) + func((x+1, y, z+4,n)) + func((x+1, y, z+5,n))+ func((x+1, y, z+6,n))+ func((x,y,z+1,n)) + func((x,y,z+1,n))) / 10
  15. return saved[f]
  16.  
  17. def converter(f):
  18. v = f.index('.')
  19. x,y = int(f[:v]), int(f[-1])
  20. return x*6+(y)
  21.  
  22. for i in range(t):
  23. x,y,z = raw_input().split()
  24. v = y.index('/')
  25. q = int(y[:v])
  26. x,y,z = converter(x), int(y[(v+1):]), int(z)
  27. print '%.2f' % (100 * func((x,y,q,z)))
Runtime error #stdin #stdout 0.08s 10840KB
stdin
Standard input is empty
stdout
Standard output is empty