Advertisement
Sanlover

Untitled

Sep 19th, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 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<2>> 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. b[k] += decimal<2>(pow(-1, k - i)) *
  26. (decimal<2>(mass[i]) /
  27. decimal<2>((fact(i) * fact(k - i) * pow(3, k))));
  28. }
  29. }
  30. for (auto& it : b)
  31. cout << it << endl;
  32. return 0;
  33. };
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement