fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using std::cin;
  4. using std::cout;
  5. using std::endl;
  6.  
  7. double foo(unsigned int N, double x)
  8. {
  9. double S = std::sqrt(x + 1);
  10. for (unsigned int n = 0; n < N; ++n)
  11. S = std::sqrt(x + (n+1) * std::floor(S));
  12. return S;
  13. }
  14.  
  15. int main()
  16. {
  17. while (true)
  18. {
  19. unsigned int N;
  20. double x;
  21. cin >> N >> x;
  22. if (cin.fail())
  23. break;
  24. cout << foo(N, x) << endl;
  25. }
  26. }
Success #stdin #stdout 0s 5568KB
stdin
2 2
3 1.5
stdout
2
2.12132