CF409E 题解
本题解为 python 题解。
给定一个正四棱锥内切半球的半径,求这个四棱锥的底边长与高。
看到题目中有
枚举每个
已知底边中心
import math
def calcu_height(b,h): #bottom&height
obl=math.sqrt(b**2+h**2) #obl为斜边长
return b*h/obl; #计算底边中心到斜高的距离
r=float(input())
for l in range(1,11):
for h in range(1,11): #l为底边长,h为高,枚举1~10
if abs(r-calcu_height(l/2,h))<=10**(-6): #题目要求的允许误差值
print(l,end=' ')
print(h,end='\n')
exit(0) #结束程序