Advertisement
Ritam_C

Uri 1289

Dec 30th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int t;
  7.     cin >> t;
  8.     while(t--){
  9.         int n, k;
  10.         double p;
  11.         cin >> n >> p >> k;
  12.         if(p == 1.000000){
  13.             if(k == 1){
  14.                 cout << fixed << setprecision(4) << 1.0 << "\n";
  15.             } else if(n > 1 && k > 1){
  16.                 cout << fixed << setprecision(4) << 0.0 << "\n";
  17.             }
  18.         }
  19.        
  20.         else{
  21.             double tp = (p*pow(1-p, k-1))/(1-pow(1-p, n));
  22.             cout << fixed << setprecision(4) << tp << "\n";
  23.    
  24.         }
  25.     }
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement