#include#include #include #define N 501using namespace std;int n;double p;double pa[N][N];double pow[N];void Init(){ memset(pa,0,sizeof(pa)); pow[0]=1; for(int i=1;i =0) pa[i][j]=pa[i-1][j]-pa[i-j-2][j]*(1-p)*pow[j+1]; } } double ans = 0; for(int i=1;i<=n;i++) { ans += (pa[n][i]-pa[n][i-1])*i; } printf("%.6lf\n",ans);}int main(){ while(scanf("%d %lf",&n,&p)!=EOF && n) { Init(); Do(); } return 0;}