From e0c587e7bff295dc26524e8adf0c656965d7c063 Mon Sep 17 00:00:00 2001 From: Luthics Date: Sun, 6 Nov 2022 14:04:19 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/3/1.py | 5 +++++ test/3/2.py | 11 +++++++++++ test/3/3.py | 5 +++++ test/3/4.py | 10 ++++++++++ 4 files changed, 31 insertions(+) create mode 100644 test/3/1.py create mode 100644 test/3/2.py create mode 100644 test/3/3.py create mode 100644 test/3/4.py diff --git a/test/3/1.py b/test/3/1.py new file mode 100644 index 0000000..ce457bc --- /dev/null +++ b/test/3/1.py @@ -0,0 +1,5 @@ +n = int(input()) +s = 1 +for i in range(n): + s *= (i + 1) +print(s) diff --git a/test/3/2.py b/test/3/2.py new file mode 100644 index 0000000..d6ed205 --- /dev/null +++ b/test/3/2.py @@ -0,0 +1,11 @@ +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)) diff --git a/test/3/3.py b/test/3/3.py new file mode 100644 index 0000000..6127354 --- /dev/null +++ b/test/3/3.py @@ -0,0 +1,5 @@ +n = int(input()) +a = [0, 1] +for i in range(2, n + 1): + a.append(a[i - 1] + a[i - 2]) # 递推 +print(a[n]) \ No newline at end of file diff --git a/test/3/4.py b/test/3/4.py new file mode 100644 index 0000000..2efd92f --- /dev/null +++ b/test/3/4.py @@ -0,0 +1,10 @@ +n = int(input()) +a = list(map(int, input().split())) +for i in range(n): + for j in range(i + 1, n): + if (a[j] < a[i]): + ls = a[i] + a[i] = a[j] + a[j] = ls +for i in range(n): + print(a[i], end=" ")