fork download
  1. # -*- coding: utf-8 -*
  2. import random
  3. def fx(x,y):
  4. a = -x*x -y*y + 1
  5. return a
  6. max = None
  7. for i in range(1000000):
  8. x = random.uniform(-1,1)
  9. y = random.uniform(-1,1)
  10. a = fx(x,y)
  11. if max == None or max < a:
  12. max = a
  13. print(max)
  14.  
Success #stdin #stdout 0.8s 11436KB
stdin
Standard input is empty
stdout
0.9999996726187538