Monday, 28 December 2015

UVA 10056 - What is the Probability? _Solution

/*
Tanzila Islam
Southeast University
mail : tanzilamohita@gmail.com
Problem Link:
https://uva.onlinejudge.org/external/100/p10056.pdf
*/

#include <bits/stdc++.h>
using namespace std;
int main(){
    int S;
    cin >> S;
    while (S--){
        int N, I;
        double p;
        cin >> N >> p >> I;
        printf("%.4lf\n", p ? pow(1.0 - p, I - 1) * p / (1 - pow(1.0 - p, N)) : 0);
    }
    return 0;
}

No comments:

Post a Comment