分析得公式为
枚举i,对于M<=i<=N都累加上 C(N, i) * (x^i) * ((1-x)^(N-i))
因为精度问题,我决定先取对数。
但是发现还是有问题,有精度问题的题不加SPJ简直是丧心病狂!!!
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<cmath>
#include<cctype>
#include<string>
#include<algorithm>
#include<iostream>
#include<ctime>
#include<map>
#include<set>
using namespace std;
#define MP(x,y) make_pair((x),(y))
#define PB(x) push_back(x)
typedef long long LL;
typedef unsigned long long ULL;
/* ****************** */
//const int INF=1000111222;
const double INFF=1e100;
const double eps=1e-8;
//const LL mod=1000000007;
const int mod=1000000007;
const int NN=100010;
const int MM=100010;
/* ****************** */
int main()
{
int cas;
int n,m,i;
double ans,temp,p,p1;
scanf("%d",&cas);
while(cas--)
{
scanf("%d%d%lf",&n,&m,&p);
p1=1.0-p;
temp=log(p)*(n+0.0);
ans=exp(temp);
//ans=C(n,n)*( p^n )*( p1^0 )
for(i=n;i>m;i--)
{
temp-=log(p);
temp+=log(p1);
temp+=log(i+0.0);
temp-=log(n-i+1.0);
ans+=exp(temp);
}
printf("%.4lf\n",ans+1e-12);//不加1e-12居然是WA!
}
return 0;
}