From 5558047439286de05bac5d40f2488654553cddc9 Mon Sep 17 00:00:00 2001 From: Luthics Date: Sun, 6 Nov 2022 14:08:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=AC=AC=E4=B8=89=E6=AC=A1?= =?UTF-8?q?=E5=AE=9E=E9=AA=8C=E7=AC=AC=E4=BA=8C=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/3/2.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/3/2.py b/test/3/2.py index d6ed205..d48a3a5 100644 --- a/test/3/2.py +++ b/test/3/2.py @@ -3,9 +3,6 @@ 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) + s += (-1)**(i % 2 + 1) / (2 * i - 1) i += 1 print(("{:." + str(a) + "f}").format(s * 4))