fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5. #define fp(i,x,n) for(ll i=x;i<n;i++)
  6. #define fn(i,x,n) for(ll i=x;i>=n;i--)
  7. #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
  8. #define f first
  9. #define s second
  10.  
  11. ll ceil(ll x, ll y)
  12. {
  13. if(!(x % y))
  14. return x/y;
  15. return (x/y)+1;
  16. }
  17.  
  18. int flag = 0;
  19.  
  20. vector<ll> V;
  21.  
  22. void rec(ll x, ll y)
  23. {
  24.  
  25. if(y > x || y==0 && x > 0)
  26. {
  27. flag = 1;
  28. return;
  29. }
  30. if(y == 0)
  31. return;
  32.  
  33. ll c = 1;
  34. ll temp;
  35.  
  36. while(1)
  37. {
  38. temp = pow(2,(ll)log2(x))/c;
  39. if(x-temp >= (y-1))
  40. break;
  41. else
  42. c*=2;
  43. }
  44.  
  45. V.push_back(temp);
  46. rec(x-temp,y-1);
  47. }
  48.  
  49. int main()
  50. {
  51. string s;
  52.  
  53. ll k,n;
  54.  
  55. cin >> n >> k;
  56.  
  57. ll n1 = n;
  58.  
  59. if(n % 2)
  60. {
  61. k--;
  62. n--;
  63. }
  64.  
  65. if(k > n)
  66. cout << "NO" << endl;
  67. else
  68. {
  69. rec(n,k);
  70. if(flag)
  71. cout << "NO" << endl;
  72. else
  73. {
  74. cout << "YES" << endl;
  75.  
  76. if(n1%2)
  77. cout << 1 << " ";
  78. fn(i,V.size()-1,0)
  79. cout << V[i] << " ";
  80.  
  81. }
  82. }
  83. }
Success #stdin #stdout 0s 15240KB
stdin
1 1
stdout
YES
1