奇怪的機率2

 avatar
user_3763047219
c_cpp
2 years ago
425 B
0
Indexable
Never
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include<math.h>

int main()
{
	int n = 0 , tplayer = 0, round = 0;
	double p = 0;
	double win=0;
	double numplayer = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %lf %lf", &tplayer, &p, &numplayer);
		double q = 1 - p;
		double r = pow(q, n);
		win = (pow(q, numplayer - 1) * p * (1 - pow(r, n))) / (1 - r);
		printf("%f\n", win);
	}
}