fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <cstdint>
  5. #include <string>
  6. #include <algorithm>
  7.  
  8. std::uint64_t F(std::uint32_t N){
  9. std::uint64_t R = N;
  10. if (N == 0) return 0;
  11. for (std::uint32_t i = N - 1; i >= 1; i--) R *= i;
  12.  
  13. return R;
  14. }
  15.  
  16.  
  17.  
  18. int main(){
  19. std::vector<std::pair<double,std::string>> vec;
  20. int N = 10;
  21. vec.push_back(std::make_pair(std::pow(2,N),"2^n"));
  22. vec.push_back(std::make_pair(std::pow(2,std::log(N)),"2^log(n)"));
  23. vec.push_back(std::make_pair(std::pow(4,N),"4^n"));
  24. vec.push_back(std::make_pair(N,"n"));
  25. vec.push_back(std::make_pair(std::pow(N,2),"n^2"));
  26. vec.push_back(std::make_pair((double)F(N),"n!"));
  27. vec.push_back(std::make_pair(N*std::log(N),"n*log(n)"));
  28. vec.push_back(std::make_pair(std::log((double)F(N)),"log(n!)"));
  29. vec.push_back(std::make_pair(std::log(std::log(N)),"log(log(n))"));
  30. vec.push_back(std::make_pair(std::sqrt(std::log(N)),"sqrt(log(n))"));
  31.  
  32. std::sort(vec.rbegin(), vec.rend());
  33.  
  34. for (auto& o : vec)std::cout << o.second << ":" << o.first << std::endl;
  35.  
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 3436KB
stdin
Standard input is empty
stdout
n!:3.6288e+06
4^n:1.04858e+06
2^n:1024
n^2:100
n*log(n):23.0259
log(n!):15.1044
n:10
2^log(n):4.93341
sqrt(log(n)):1.51743
log(log(n)):0.834032