Algorithm
Code Examples
#1 Code Example with Python Programming
Code -
Python Programming
i, n = map(int, input().split())
check = False
def solve(i, n, p):
global check
if i == n:
check = True
print("YES")
print(len(p))
print(*p)
return
if(i < n):
solve(2*i, n, p + [2*i])
solve(10*i + 1, n, p + [10*i+1])
#backtracking
solve(i, n, [i])
if not check:
print("NO">
Copy The Code &
Try With Live Editor
Input
2 162
Output
YES
5
2 4 8 81 162
5
2 4 8 81 162
Demonstration
Codeforcess Solution 727-A A. Transformation: from A to B ,C++, Java, Js and Python ,727-A,Codeforcess Solution