Added task 22

This commit is contained in:
Dmitriy Shishkov 2020-11-27 20:54:53 +05:00
parent 02d2d37492
commit 33caa3977f
No known key found for this signature in database
GPG Key ID: D76D70029F55183E
8 changed files with 199 additions and 0 deletions

24
22/19.py Normal file
View File

@ -0,0 +1,24 @@
s, t = 11, 27
c = []
n = []
arr = [1] * (s + 1)
for k in range(len(c) + 1):
s__ = s + 1 if k == 0 else c[k - 1] + 1
s_ = s__ - 1
t__ = c[k] + 1 if k < len(c) else t + 1
t_ = t__ - 1
for i in range(s__, t__):
e = 0
if i - 1 >= s_ and not i - 1 in n:
e += arr[i - 1]
if (i % 100) // 10 > 0 and i - 10 >= s_ and not i - 10 in n:
e += arr[i - 10]
arr.append(e)
back = arr[t_]
arr = [0] * (t_ + 1)
arr[t_] = back
print(arr[t])
# 8

24
22/49.py Normal file
View File

@ -0,0 +1,24 @@
s, t = 2, 11
c = []
n = []
arr = [1] * (s + 1)
for k in range(len(c) + 1):
s__ = s + 1 if k == 0 else c[k - 1] + 1
s_ = s__ - 1
t__ = c[k] + 1 if k < len(c) else t + 1
t_ = t__ - 1
for i in range(s__, t__):
e = 0
if i - 1 >= s_ and not i - 1 in n:
e += arr[i - 1]
if i % 2 == 1 and (i + 1) // 2 >= s_ and not (i + 1) // 2 in n:
e += arr[(i+1) // 2]
arr.append(e)
back = arr[t_]
arr = [0] * (t_ + 1)
arr[t_] = back
print(arr[t])
# 14

25
22/50.py Normal file
View File

@ -0,0 +1,25 @@
s, t = 3, 20
c = []
n = []
arr = [1] * (s + 1)
for k in range(len(c) + 1):
s__ = s + 1 if k == 0 else c[k - 1] + 1
s_ = s__ - 1
t__ = c[k] + 1 if k < len(c) else t + 1
t_ = t__ - 1
for i in range(s__, t__):
e = 0
if i - 1 >= s_ and not i - 1 in n:
e += arr[i - 1]
if i != t // 2:
if i % 2 == 0 and i // 2 >= s_ and not i // 2 in n:
e += arr[i // 2]
arr.append(e)
back = arr[t_]
arr = [0] * (t_ + 1)
arr[t_] = back
print(arr[t])
# 16

24
22/67.py Normal file
View File

@ -0,0 +1,24 @@
s, t = 5, 25
c = [15]
n = [12]
arr = [1] * (s + 1)
for k in range(len(c) + 1):
s__ = s + 1 if k == 0 else c[k - 1] + 1
s_ = s__ - 1
t__ = c[k] + 1 if k < len(c) else t + 1
t_ = t__ - 1
for i in range(s__, t__):
e = 0
if i - 1 >= s_ and not i - 1 in n:
e += arr[i - 1]
if i - 3 >= s_ and not i - 3 in n:
e += arr[i - 3]
arr.append(e)
back = arr[t_]
arr = [0] * (t_ + 1)
arr[t_] = back
print(arr[t])
# 280

26
22/75.py Normal file
View File

@ -0,0 +1,26 @@
s, t = 3, 13
c = []
n = [8]
arr = [1] * (s + 1)
for k in range(len(c) + 1):
s__ = s + 1 if k == 0 else c[k - 1] + 1
s_ = s__ - 1
t__ = c[k] + 1 if k < len(c) else t + 1
t_ = t__ - 1
for i in range(s__, t__):
e = 0
if i - 1 >= s_ and not i - 1 in n:
e += arr[i - 1]
if i - 2 >= s_ and not i - 2 in n:
e += arr[i - 2]
if i % 2 == 0 and i // 2 >= s_ and not i // 2 in n:
e += arr[i // 2]
arr.append(e)
back = arr[t_]
arr = [0] * (t_ + 1)
arr[t_] = back
print(arr[t])
# 40

24
22/82.py Normal file
View File

@ -0,0 +1,24 @@
s, t = 1, 31
c = []
n = [25]
arr = [1] * (s + 1)
for k in range(len(c) + 1):
s__ = s + 1 if k == 0 else c[k - 1] + 1
s_ = s__ - 1
t__ = c[k] + 1 if k < len(c) else t + 1
t_ = t__ - 1
for i in range(s__, t__):
e = 0
if i - 1 >= s_ and not i - 1 in n:
e += arr[i - 1]
if (i - 1) % 2 == 0 and (i - 1) // 2 >= s_ and not (i - 1) // 2 in n:
e += arr[(i - 1) // 2]
arr.append(e)
back = arr[t_]
arr = [0] * (t_ + 1)
arr[t_] = back
print(arr[t])
# 44

26
22/90.py Normal file
View File

@ -0,0 +1,26 @@
s, t = 2, 15
c = [4, 11]
n = []
arr = [1] * (s + 1)
for k in range(len(c) + 1):
s__ = s + 1 if k == 0 else c[k - 1] + 1
s_ = s__ - 1
t__ = c[k] + 1 if k < len(c) else t + 1
t_ = t__ - 1
for i in range(s__, t__):
e = 0
if i - 1 >= s_ and not i - 1 in n:
e += arr[i - 1]
if i - 2 >= s_ and not i - 2 in n:
e += arr[i - 2]
if i % 3 == 0 and i // 3 >= s_ and not i // 3 in n:
e += arr[i // 3]
arr.append(e)
back = arr[t_]
arr = [0] * (t_ + 1)
arr[t_] = back
print(arr[t])
# 210

26
22/util.py Normal file
View File

@ -0,0 +1,26 @@
s, t = 3, 20
c = [9]
n = [15]
arr = [1] * (s + 1)
for k in range(len(c) + 1):
s__ = s + 1 if k == 0 else c[k-1] + 1
s_ = s__ - 1
t__ = c[k] + 1 if k < len(c) else t + 1
t_ = t__ - 1
for i in range(s__, t__):
e = 0
if i - 1 >= s_ and not i - 1 in n:
e += arr[i-1]
if i - 2 >= s_ and not i - 2 in n:
e += arr[i-2]
# if i % 2 == 0 and i // 2 >= s_ and not i // 2 in n:
# e += arr[i // 2]
arr.append(e)
back = arr[t_]
arr = [0] * (t_ + 1)
arr[t_] = back
print(arr[t])
# 280