Advertisement
Artem_Chepurov

Untitled

Sep 26th, 2022
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <time.h>
  4. #include <omp.h>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. double N = 86000000, sum = 0.0;
  10. clock_t t1, t2;
  11. double time, total = 0.0;
  12. int n = 1;
  13. t1 = clock();
  14. #pragma omp parallel for private(n,sum) reduction(+:total)
  15. for(n = 1; n <= N; n++)
  16. {
  17. sum = pow(-1, n) / (pow((2 * n + 1), 3) - 1);
  18. total += sum;
  19. }
  20. t2 = clock();
  21. time = (t2 - t1) / (double)CLOCKS_PER_SEC;
  22. cout << time << endl <<total;
  23.  
  24. }
  25.  
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement