-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14-1.py
44 lines (39 loc) · 808 Bytes
/
14-1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
result = "100*100="
ary = []
ary2 = []
i = 100
while i >= 2:
tmp_ary = []
result += "("
result += str(i)
ary.append(i)
tmp_ary.append(i)
result += "+"
result += str(i - 1)
ary.append(i - 1)
tmp_ary.append(i - 1)
result += "+"
result += str(i - 1)
ary.append(i - 1)
tmp_ary.append(i - 1)
result += "+"
result += str(i - 2)
ary.append(i - 2)
tmp_ary.append(i - 2)
result += ")"
if i != 2:
result += "+"
i = i - 2
ary2.append(tmp_ary)
print(result)
print(ary2)
sum = 0
for i in range(len(ary)):
sum += ary[i]
print("sum is: {}, and ary's length is: {}".format(sum, len(ary)))
for i in range(len(ary2)):
sum = 0
for j in range(len(ary2[i])):
sum += ary2[i][j]
print(sum)
print(len(ary2))