http://oj.acm.zstu.edu.cn/JudgeOnline/problem.php?id=4255
题解:DFS裸题
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=1e9;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
ll t,n,m,k,q,ans;
ll a[N],b;
char str;
bool dfs(ll c,ll cnt){
if(c==m){
ans=cnt-1;
return true;
}
if(c>M){
return false;
}//cout<<c<<" "<<cnt<<endl;
a[cnt]=c*2;
if(dfs(c*2,cnt+1))
return true;
a[cnt]=c*10+1;
if(dfs(c*10+1,cnt+1))
return true;
return false;
}
int main()
{
#ifdef DEBUG
freopen("input.in", "r", stdin);
//freopen("output.out", "w", stdout);
#endif
while(~scanf("%lld%lld",&n,&m)){
a[0]=n;
if(dfs(n,1)){
printf("YES %d\n",ans);
for(int i=0;i<ans;i++){
printf("%lld ",a[i]);
}
printf("%lld\n",a[ans]);
}else{
printf("NO\n");
}
}
//cout << "Hello world!" << endl;
return 0;
}