fork download
  1. //Bai 4
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5. #define el "\n"
  6. #define ll long long
  7. #define ull unsigned long long
  8. #define se second
  9. #define fi first
  10. #define be begin()
  11. #define en end()
  12. #define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
  13.  
  14. void Run(ll n)
  15. {
  16. vector<ll> vt;
  17. for(int i = 1; i <= sqrt(n); i++)
  18. {
  19. if(n % i == 0)
  20. {
  21. vt.push_back(i);
  22. if(n / i != i) vt.push_back(n / i);
  23. }
  24. }
  25. sort(vt.be, vt.en);
  26. for(auto x : vt) cout << x << " ";
  27. }
  28. int main()
  29. {
  30. Faster;
  31. ll n; cin >> n;
  32. Run(n);
  33. return 0;
  34. }
  35.  
  36.  
Success #stdin #stdout 0.11s 5280KB
stdin
Standard input is empty
stdout
1 2 4 8 16 32 64 128 256 991 1982 3964 7928 15856 31712 63424 126848 253696 554698577 1109397154 2218794308 4437588616 8875177232 17750354464 35500708928 71001417856 142002835712 549706289807 1099412579614 2198825159228 4397650318456 8795300636912 17590601273824 35181202547648 70362405095296 140724810190592