codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

727A.md (1735B)


      1 Source: https://codeforces.com/problemset/problem/727/A
      2 
      3 A. Transformation: from A to B
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Vasily has a number *a*, which he wants to turn into a number *b*. For this purpose, he can do two types of operations:
     22 
     23 * multiply the current number by 2 (that is, replace the number *x* by 2·*x*);
     24 * append the digit 1 to the right of current number (that is, replace the number *x* by 10·*x* + 1).
     25 
     26 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.
     27 
     28 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*.
     29 
     30 Input
     31 
     32 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.
     33 
     34 Output
     35 
     36 If there is no way to get *b* from *a*, print "NO" (without quotes).
     37 
     38 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 *x*1, *x*2, ..., *x**k*, where:
     39 
     40 * *x*1 should be equal to *a*,
     41 * *x**k* should be equal to *b*,
     42 * *x**i* should be obtained from *x**i* - 1 using any of two described operations (1 < *i* ≤ *k*).
     43 
     44 If there are multiple answers, print any of them.
     45 
     46 Examples
     47 
     48 Input
     49 
     50 ```
     51 2 162
     52 ```
     53 
     54 Output
     55 
     56 ```
     57 YES  
     58 5  
     59 2 4 8 81 162
     60 ```
     61 
     62 Input
     63 
     64 ```
     65 4 42
     66 ```
     67 
     68 Output
     69 
     70 ```
     71 NO
     72 ```
     73 
     74 Input
     75 
     76 ```
     77 100 40021
     78 ```
     79 
     80 Output
     81 
     82 ```
     83 YES  
     84 5  
     85 100 200 2001 4002 40021
     86 ```