Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                               Online C++ Compiler.
  4.                Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.     double p = 0.01;
  16.     double q = 1-p;
  17.     double r = 0;
  18.     int n = 50;
  19.     double d = 50*49/2;
  20.     d *= p * p;
  21.     for(int i = 0; i<48; i++) d*=q;
  22.     r += d;
  23.     d = 50;
  24.     d*=p;
  25.     for(int i = 0; i<49; i++) d*=q;
  26.     r += d;
  27.     d=1;
  28.     for(int i = 0; i<50; i++) d*=q;
  29.     r+=d;
  30.     cout<<r;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement