根据概率公式dfs即可,判断和区间[T-E,T+E]是否有交,控制层数。

#include<bits/stdc++.h>
using namespace std;
int K,R,L;
double P,E,T;
double Lt,Rt;
double dfs(double L,double R,int k = )
{
if(R<Lt || L>Rt) return ;
if(Lt < L && R < Rt) return ;
double H = (L+R)/;
if(k == K) return (Lt<H && H<Rt)?.:.;
double p = T<H?-P:P;
return dfs(L,H,k+)*p + dfs(H,R,k+)*(.-p);
} //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
scanf("%d%d%d",&K,&L,&R);
scanf("%lf%lf%lf",&P,&E,&T);
Lt = T-E, Rt = T+E;
printf("%lf\n",dfs(L,R));
return ;
}
05-23 03:09