time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

 

Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations:

  • multiply the current number by 2 (that is, replace the number x by 2·x);
  • append the digit 1 to the right of current number (that is, replace the number x by 10·x + 1).

You need to help Vasily to transform the number a into the number b using only the operations described above, or find that it is impossible.

Note that in this task you are not required to minimize the number of operations. It suffices to find any way to transform a into b.

Input

The first line contains two positive integers a and b (1 ≤ a < b ≤ 109) — the number which Vasily has and the number he wants to have.

Output

If there is no way to get b from a, print "NO" (without quotes).

Otherwise print three lines. On the first line print "YES" (without quotes). The second line should contain single integer k — the length of the transformation sequence. On the third line print the sequence of transformations x1, x2, ..., xk, where:

  • x1 should be equal to a,
  • xk should be equal to b,
  • xi should be obtained from xi - 1 using any of two described operations (1 < i ≤ k).

If there are multiple answers, print any of them.

Examples
input
2 162
output
YES
5
2 4 8 81 162
input
4 42
output
NO
input
100 40021
output
YES
5
100 200 2001 4002 40021

题意:

有两种变换方式:

(1)x*10+1

(2)x*2

问a能否经过两种变换转换成b

如果b是奇数,则必是由(1)方式转换而来,若为偶数则必是(2)转换而来。

附AC代码:

 #include<bits/stdc++.h>
using namespace std; int c[]; int main(){
int a,b;
cin>>a>>b;
int ans=;
c[]=b;
int flag=;
while(a<b){
if((b-)%==){
b=(b-)/;
c[ans++]=b;
}
else if(b%==){
b/=;
c[ans++]=b;
}
else{
flag=;
break;
}
}
if(flag==){
cout<<"NO"<<endl;
}
else if(a==b){
cout<<"YES"<<endl;
cout<<ans<<endl;
for(int i=ans-;i>=;i--){
cout<<c[i]<<" ";
}
}
else{
cout<<"NO"<<endl;
}
return ;
}

A. Transformation: from A to B的更多相关文章

  1. (七)Transformation和action详解-Java&Python版Spark

    Transformation和action详解 视频教程: 1.优酷 2.YouTube 什么是算子 算子是RDD中定义的函数,可以对RDD中的数据进行转换和操作. 算子分类: 具体: 1.Value ...

  2. 线性分式变换(linear fractional transformation)

    线性分式变换(linear fractional transformation)的名称来源于其定义的形式:(ax+b)/(cx+d),其中分子分母是线性的,然后最外层是一个分式形式,所以叫做这个名字, ...

  3. OLE DB Command transformation 用法

    OLE DB Command transformation component 能够引用参数,逐行调用sqlcommand,This transformation is typically used ...

  4. OpenCASCADE General Transformation

    OpenCASCADE General Transformation eryar@163.com Abstract. OpenCASCADE provides a general transforma ...

  5. Informatica Lookup Transformation组件的Connect 与Unconnected类型用法

    Informatica Lookup Transformation组件的Connect 与Unconnected类型用法及区别:下面是通一个Lookup在不同Mapping中的使用: 1. Conne ...

  6. Data Transformation / Learning with Counts

    机器学习中离散特征的处理方法 Updated: August 25, 2016 Learning with counts is an efficient way to create a compact ...

  7. VS非web项目使用Transformation配置文件

    Web项目中的Transformation使用起来非常方便,特别是本地与服务器情况不一致时调试下以及webdeploy的配合使用. 步骤: 1. 在项目中新建App.Debug.Config及App. ...

  8. SAP SLT (Landscape Transformation) 企业定制培训

    No. Item Remark 1 SAP SLT概述 SAP Landscape Transformation Overview 2 SAP SLT 安装与配置<1> for abap ...

  9. Scalaz(55)- scalaz-stream: fs2-基础介绍,fs2 stream transformation

    fs2是scalaz-stream的最新版本,沿用了scalaz-stream被动式(pull model)数据流原理但采用了全新的实现方法.fs2比较scalaz-stream而言具备了:更精简的基 ...

  10. 使用Web.Config Transformation配置灵活的配置文件

    发布Asp.net程序的时候,开发环境和发布环境的Web.Config往往不同,比如connectionstring等.如果常常有发布的需求,就需要常常修改web.config文件,这往往是一件非常麻 ...

随机推荐

  1. ClassLoader Java中类加载出现在哪个阶段,编译期和运行期? 类加载和类装载是一样的吗

    1.ClassLoader Java中类加载出现在哪个阶段,编译期和运行期? 类加载和类装载是一样的吗? :当然是运行期间啊,我自己有个理解误区,改正后如下:编译期间编译器是不去加载类的,只负责编译而 ...

  2. 第二讲_图像数据处理Image Data Processing

    第二讲_图像数据处理Image Data Processing 深度模型出现后被弱化,但是思想的影子在深度模型中可以看到的 图片存储原理 RGB颜色空间:三通道(b,g,r),加法混色 CMY(K): ...

  3. 转:我们是怎么做Code Review的

    我们是怎么做Code Review的   前几天看了<Code Review 程序员的寄望与哀伤>,想到我们团队开展Code Review也有2年了,结果还算比较满意,有些经验应该可以和大 ...

  4. oracle spm使用1

    oracle11g new feature SPM 有助于保持sql的语句特性,仅仅同意运行性能提高的运行计划. 它不同于stored outlines, spm在于稳定sql性能,而store ou ...

  5. ArcGIS 10.3 for Server新特性介绍

    ArcGIS10.3的正式版立即在美国Esri全球用户大会推出.中国的正式发行时间预计在Esri中国的用户大会.以下就将用户比較关心的ArcGIS 10.3 for Server的新特性给大家进行简单 ...

  6. Jenkins+appium+testng持续集成

    Create maven project in eclipseAdd Appium , Selenium dependancyAdd Test in TestNG testCreate TestNG ...

  7. eclipse配置android

    先在eclipse中安装ADT插件,install内点击add,name:ADT, URL:http://dl-ssl.google.com/android/eclipse/ 之后直接finish就好 ...

  8. GuozhongCrawler系列教程 (5) TransactionRequest具体解释

    为了实现和维护并发抓取的属性信息提供线程安全的事务请求.TransactionRequest是一个抽象类自己不能设置Processor,却须要实现 TransactionCallBack接口.Tran ...

  9. Mac版的idea部分按钮失效的解决方案

    问题描述:调整了一下idea中jdk的路径,之后idea就无法打开新项目了,最好发现idea中的顶部菜单全部失效 解决过程: 1.把idea的jdk的路径调回去,无效 2.重启idea,无效 3.重启 ...

  10. oracle的索引有几种?各有何用途?

    1. b-tree索引Oracle数据库中最常见的索引类型是b-tree索引,也就是B-树索引,以其同名的计算科学结构命名.CREATE INDEX语句时,默认就是在创建b-tree索引.没有特别规定 ...