fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. class SortEstimate
  5. {
  6. public:
  7.  
  8. double howMany(int c, int time){
  9.  
  10. long double x = 7;
  11. long double r = double(time)/double(c);
  12. for (int i = 0; i<1000; i++) {
  13. x = x - (x * log(x)/log(2.0) - r)/(1.0 + log(x)/log(2.0));
  14. }
  15. return x;
  16.  
  17. }
  18. };
  19.  
  20. int main()
  21. {
  22. SortEstimate sort;
  23. cout<<sort.howMany(1,8)<<endl;//4
  24. cout<<sort.howMany(2,16)<<endl;//4
  25. cout<<sort.howMany(37,12392342)<<endl;//23105
  26. cout<<sort.howMany(1,2000000000)<<endl;//7.6375e+07
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
4
4
23105
7.6375e+07