artemgf

Холодильник

May 7th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <string>
  5. #include <set>
  6. #include <map>
  7. #include <algorithm>
  8. #include <string>
  9. #include <math.h>
  10. #include <vector>
  11. #include <cmath>
  12. #include <sstream>
  13.  
  14. using namespace std;
  15.  
  16. int main()
  17. {
  18.     long long n;
  19.     vector <long long> answ;
  20.  
  21.     cin >> n;
  22.  
  23.     while (n > 1)
  24.     {
  25.         answ.push_back(n / 2);
  26.         n -= n / 2;
  27.     }
  28.  
  29.     cout << answ.size() << endl;
  30.  
  31.     for (auto i = answ.begin(); i != answ.end(); i++)
  32.         cout << *i << " ";
  33.    
  34.  
  35.     _getch();
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment