Advertisement
nq1s788

23 дерево вариантов, есть вычитание

Mar 22nd, 2025
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. #https://kpolyakov.spb.ru/school/ege/gen.php?action=viewVar&answers=on&varId=10
  2. def step(x, f, path):
  3.     global answ
  4.     if x > 63:
  5.         return
  6.     if x == 62:
  7.         if 32 in path:
  8.             answ += 1
  9.         return
  10.     if ((x * 3) % 10 != 0) and ((x * 3) not in path):
  11.         step(x * 3, False, path | {x * 3})
  12.     if ((x + 2) % 10 != 0) and ((x + 2) not in path):
  13.         step(x + 2, False, path | {x + 2})
  14.     if (not f) and ((x - 1) % 10 != 0) and ((x - 1) not in path):
  15.         step(x - 1, True, path | {x - 1})
  16.  
  17.  
  18. answ = 0
  19. step(5, False, {5})
  20. print(answ)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement