fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. // номер 8 P2
  5. double fp, fpp, fppp;
  6. cin >> fppp >> fpp >> fp;
  7. int n;
  8. double x;
  9. cin >> n >> x;
  10. double ans = 0;
  11. if (n >= 0) ans += fppp;
  12. if (n >= 1) ans += fpp*x;
  13. if (n >= 2) ans += fp*x*x;
  14. double X = x*x*x;
  15. for (int i = 3; i <= n; i += 1) {
  16. const double f = fp * fpp - 3 * fppp;
  17. X *= x;
  18. ans += X * f;
  19. fppp = fpp;
  20. fpp = fp;
  21. fp = f;
  22. }
  23. cout << ans << "\n";
  24. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
-nan