height,weight = eval(input())
bmi = weight / pow(height,2)
print("BMI 数值为:{:.2f}".format(bmi))
who,nat = "",""
if bmi < 18.5:
who,nat = "偏瘦","偏瘦"
elif 18.5 <= bmi < 24:
who,nat = "正常","正常"
elif 24 <= bmi < 25:
who,nat = "正常","偏胖"
elif 25 <= bmi < 28:
who,nat = "偏胖","偏胖"
elif 28 <= bmi <30:
who,nat = "偏胖","肥胖"
else:
who,nat = "肥胖","肥胖"
print("BMI指标为:国际'{}',国内'{}'".format(who,nat))
import random
DARTS = eval(input())
hits = 0.0
random.seed(123)
for i in range(1,DARTS+1):
x,y = random.random(),random.random()
dist = pow(x**2 + y**2,0.5)
if dist <=1.0:
hits = hits + 1
pi = 4 * (hits/DARTS)
print("{:.6f}".format(pi))
#公式方法
pi = 0
N = 100 #循环的数量或累加的数量
for i in range(N):
pi = pi + 1/pow(16,i)*(4/(8*i+1)-2/(8*i+4)-1/(8*i+5)-1/(8*i+6))
print("圆周率值是:{}".format(pi))
#蒙特卡罗方法
import time,random
DARTS = eval(input())
hits = 0.0
strt = time.perf_counter()
random.seed(123)
for i in range(1,DARTS+1):
x,y = random.random(),random.random()
dist = pow(x**2 + y**2,0.5)
if dist <=1.0:
hits = hits + 1
pi = 4 * (hits/DARTS)
print("圆周率值是:{:.6f}".format(pi))
print("运行结束时间为:{}".format(time.perf_counter()-strt))
sum = 0
for i in range(1,967):
if i % 2 ==0: #偶数为负
sum = sum-i
else:
sum =sum +i #奇数为正
print(sum)