I-th
玩家成功機率S
代表測資數N
p
I
所以一起來膜拜專業解釋吧
[Uva10056] What is the Probability?
但裡面提到回合數的問題
我寫到 100000 才會過 QQ
#include<stdio.h>
#include<math.h>
int main(){
int S;
int N, i;
double p, q;
double a, r;
scanf("%d", &S);
while(S--){
scanf("%d %lf %d", &N, &p, &i);
q = 1 - p;
a = pow(q, i - 1) * p;
r = pow(q, N);
if(p == 0){
printf("0.0000\n");
}
else{
printf("%.4lf\n", (a * (1 - pow(r, 100000)) / (1 - r)));
}
}
return 0;
}