Advertisement
Korotkodul

N23_v2

Jun 12th, 2023 (edited)
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. dp1 = [0]* (10**4 + 10)
  2. dp2 = [0] * (10**4 + 10)
  3. dp1[1] = 1
  4. for i in range(2,3000):
  5.     s = 0
  6.     if i - 3 >= 1:
  7.         s += dp1[i - 3]
  8.     if i - 5 >= 1:
  9.         s += dp1[i - 5]
  10.     if i % 2 == 0:
  11.         s += dp1[i // 2]
  12.     dp1[i] = s
  13. dp1[3000] = 1
  14. for i in range(3001,10**4+10):
  15.     if i == 5000:
  16.         continue
  17.     s = 0
  18.     if i - 3 >= 3000:
  19.         s += dp1[i - 3]
  20.     if i - 5 >= 3000:
  21.         s += dp1[i - 5]
  22.     if i % 2 == 0 and i // 2 >= 3000:
  23.         s += dp1[i // 2]
  24.     dp1[i] = s
  25. to3000 = dp1[1500] + dp1[2997] + dp1[2995]
  26. A = to3000 * dp1[10**4]
  27.  
  28. dp2[1] = 1
  29. for i in range(2,5000):
  30.     if i == 3000:
  31.         continue
  32.     s = 0
  33.     if i - 3 >= 1:
  34.         s += dp2[i - 3]
  35.     if i - 5 >= 1:
  36.         s += dp2[i - 5]
  37.     if i % 2 == 0:
  38.         s += dp2[i // 2]
  39.     dp2[i] = s
  40. dp2[5000] = 1
  41. for i in range(5001, 10**4 + 10):
  42.     s = 0
  43.     if i - 3 >= 5000:
  44.         s += dp2[i - 3]
  45.     if i - 5 >= 5000:
  46.         s += dp2[i - 5]
  47.     if i % 2 == 0 and i // 2 >= 5000:
  48.         s += dp2[i // 2]
  49.     dp2[i] = s
  50. to5000 = dp2[2500] + dp2[4997] + dp2[4995]
  51. B = to5000 * dp2[10**4]
  52. C = A + B
  53. s = str(C)
  54. print(s[-6:])
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement