fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int e=1, n;
  8. double x, t, o=0;
  9.  
  10. cin >> n >> x;
  11.  
  12. for (int j=1; j<(n+1); j++)
  13. {
  14. t=sin(j*x);
  15. e*=2;
  16. o+=t/e;
  17. }
  18.  
  19. cout << fixed << o;
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 4348KB
stdin
10 0.523598
stdout
0.651170