#include<bits/stdc++.h>using namespace std;int x,n,pp,ct[10000];long double f[210][(1<<8)+5][240][2],p,ans;int main(){freopen("exp.in","r",stdin);freopen("exp.out","w",stdout);scanf("%d%d%d",&x,&n,&pp);p=pp/100.0;for(int i=1;i<=2000;i++)ct[i*2]=ct[i]+1;int d=x&1,b=x&255,c=0;x>>=8;while(x&&(x&1)==d){x>>=1;c++;}f[0][b][c][d]=1.0;for(int i=0;i<n;i++)for(int j=0;j<=255;j++)for(int k=0;k<=230;k++)for(int l=0;l<=1;l++){int b,c,d;if(j==255){b=0;if(l==1){d=0;c=k;}else{d=1;c=1;}}else{b=j+1;d=l;c=k;}f[i+1][b][c][d]=f[i+1][b][c][d]+f[i][j][k][l]*(1-p);//+1if(j>127){b=(j*2)&255;int td=(j*2)&256;td>>=8;if(td!=l){c=1;d=td;}else{c=k+1;d=l;}}else{b=j*2;if(l!=0){d=0;c=1;}else{d=0;c=k+1;}}f[i+1][b][c][d]=f[i+1][b][c][d]+f[i][j][k][l]*p;//*2}for(int j=1;j<=255;j++)for(int k=0;k<=230;k++)for(int l=0;l<=1;l++)ans=ans+f[n][j][k][l]*ct[j];for(int k=0;k<=230;k++)ans=ans+f[n][0][k][1]*8+f[n][0][k][0]*(8+k);printf("%.12Lf\n",ans);}
我怎麼天天犯傻逼錯誤!