fork download
  1. /** e==m*pow(c,2) **/
  2.  
  3. #include<bits/stdc++.h>
  4. #define lli long long int
  5. #define pii pair<lli, lli>
  6. #define pb push_back
  7. #define endl '\n'
  8. #define yes cout<<"YES"<<endl
  9. #define no cout<<"NO"<<endl
  10.  
  11. using namespace std;
  12. int main()
  13. {
  14. ios_base::sync_with_stdio(false);
  15. cin.tie();
  16. cout.tie();
  17. priority_queue<int> q;
  18. long long int power[60];power[0]=1;
  19. for(int i=1;i<=60;i++) power[i]= power[i-1]*2LL;
  20. long long int a;
  21. int k, m;
  22. cin >> a >> k;
  23. while(a)
  24. {
  25. m = log2(a);
  26. q.push(m);
  27. a -= power[m];
  28. k--;
  29. }
  30. while(k)
  31. {
  32. m = q.top();
  33. q.pop();
  34. q.push(m-1);
  35. q.push(m-1);
  36. k--;
  37. }
  38. while(!q.empty())
  39. {
  40. cout<<q.top()<<' ';
  41. q.pop();
  42. }
  43. return 0;
  44. }
  45.  
  46.  
  47.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty