題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=997
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #include <iostream> #include <iomanip> #include <cmath>
using namespace std;
int main(){ int s; cin >> s; while(s--){ int n, i; double p; cin >> n >> p >> i; if(p == 0.0){ cout << fixed << setprecision(4) << 0.0 << '\n'; continue; }
double a = p * pow(1-p, i-1); double b = 1 - pow(1-p, n); cout << fixed << setprecision(4) << a/b << '\n'; } return 0; }
|