Advertisement
Sanlover

Untitled

Sep 19th, 2021
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <cmath>
  2. #include <iomanip>
  3. #include <iostream>
  4. #include <string>
  5. #include <vector>
  6. #include "decimal_for_cpp/include/decimal.h"
  7. using namespace std;
  8. using namespace dec;
  9.  
  10. int fact(int N) {
  11. if (N < 0)
  12. return 0;
  13. if (N == 0)
  14. return 1;
  15. else
  16. return N * fact(N - 1);
  17. }
  18.  
  19. vector<decimal<10>> b(7);
  20. vector<int> mass = {9, 36, 81, 144, 225, 324, 441};
  21.  
  22. int main() {
  23. for (int k = 0; k < 7; k++) {
  24. for (int i = 0; i <= k; i++) {
  25. decimal<2> first(pow(-1, k - i));
  26. decimal<2> second(mass[i]);
  27. decimal<2> third(fact(i));
  28. decimal<2> fourth(fact(k - i));
  29. decimal<2> fiveth(pow(3, k));
  30. b[k] += first * (second / (third * fourth * fiveth));
  31. }
  32. }
  33. for (auto& it : b)
  34. cout << it << endl;
  35. return 0;
  36. };
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement