Advertisement
gha890826

0312-2 機率問題

Mar 12th, 2021 (edited)
638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include<iomanip>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int s;
  9.     while(cin>>s)
  10.     {
  11.         while(s>0)
  12.         {
  13.             int n=0,i=0;
  14.             double p=0;
  15.             cin>>n>>p>>i;
  16.             double q=1-p;
  17.             double ans=pow(q,i-1)*p/(1-pow(q,n));
  18.             cout<<setprecision(4)<<ans<<endl;
  19.            
  20.             s--;
  21.         }
  22.     }
  23.     return 0;
  24. }
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement