思路
从b推a,
如果b为偶数,b /= 2;
如果b mod 10 ==1,b = (b-1)/10;
如果b mod 10 == {3,5,7,9}等,输出”NO”
#include<bits/stdc++.h>
using namespace std;
int path[1000];
int k=0;
int main(){
int a,b;
cin>>a>>b;
path[k++]=b;
while(b > a){
if(b%10==1)
b = (b-1)/10;
else if(!(b&1))
b =b/2;
else
{
printf("NO\n");
return 0;
}
path[k++]=b;
}
if(b == a){
printf("YES\n%d\n",k);
for(auto i=k-1;i>=0;i--)
printf("%d ",path[i]);
}
else if(b < a)
printf("NO\n");
}