XJTU_Python/test/3/2.py

12 lines
296 B
Python

n = input()
a = int(n.split('-')[1]) # 暴力取出小数位数和精度
i = 1
s = 0
while (1 / (2 * i - 1) >= 10**(-a)): # 精度要求作为条件
if (i % 2 == 0):
s -= 1 / (2 * i - 1)
else:
s += 1 / (2 * i - 1)
i += 1
print(("{:." + str(a) + "f}").format(s * 4))