#pi.py
#code=utf8

from random import *
from math import *
from time import *

for DARTS in [5000,50000,500000,5000000,50000000,500000000]:
    hits=0
    clock()
    for i in range(1,DARTS):
        x,y=random(),random()
        dist = sqrt(x**2 + y**2)
        if dist <= 1.0:
            hits=hits+1
    pi= 4*(hits/DARTS)

    print("抛点数：%s, Pi值是：%s， 程序运行：%-5.5ss" % (DARTS , pi , clock()))
