Advertisement
DimaT1

Untitled

Oct 15th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. // 1
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. bool flag = false;
  8.  
  9. void make(long long a, long long b, vector<long long> &p) {
  10. if(a == b) {
  11. flag = true;
  12. }
  13. else if(a > b) {
  14. //bad
  15. }
  16. else {
  17. p.push_back(a*2);
  18. make(a*2, b, p);
  19. if(!flag) {
  20. p.erase(p.end()-1);
  21.  
  22. p.push_back(a*10+1);
  23. make(a*10+1, b, p);
  24. if(!flag) {
  25. p.erase(p.end()-1);
  26. }
  27. }
  28. }
  29. }
  30.  
  31. int main()
  32. {
  33. long long a, b;
  34. cin >> a >> b;
  35. vector<long long> p;
  36. p.push_back(a);
  37.  
  38. make(a, b, p);
  39.  
  40. if(p.size() == 1) {
  41. cout << "NO"<< endl;
  42. return 0;
  43. }
  44. cout << "YES" << endl;
  45. cout << p.size() << endl;
  46. for(int i = 0; i < p.size(); i++)
  47. cout << p[i] << ' ';
  48.  
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement