求高精度幂 为什么没过?。
# include<stdio.h># include<string>
int main()
{
int d,e,r,w,i,j,n,m,a,b,k,z[128],x[128],c[128],u,v,f;
char q[128];
while (scanf("%s %d",&q,&k)!=EOF) {
for (i=0;i<128;i++)
{c[i]=0; z[i]=0;}
r=0;
b=-1;
a=strlen(q);
for (i=0;i<a;i++)
if (q[i]=='.') b=i;
n=0;
for (i=0;i<a;i++)
if (i!=b) {z[n]=q[i]-'0';n=n+1;}
for (i=0;i<n;i++) { x[n-1-i]=z[i]; }
for (i=0;i<n;i++) z[i]=x[i];
d=n;
u=k*(n-b);
u=u-1;
for (e=0;e<k-1;e++){
for (i=0;i<d;i++)
for (j=0;j<n;j++)
{c[i+j]=c[i+j]+z[i]*x[j];}
for (i=128;i>=0;i--) if (c[i]!=0) {d=i; break;} d=d+1;
for (i=0;i<d;i++)
while (c[i]>=10)
{c[i]=c[i]-10;
c[i+1]=c[i+1]+1; }
for (i=128;i>=0;i--) if (c[i]!=0) {d=i; break;} d=d+1;
for(i=0;i<d;i++) z[i]=c[i];
for (i=0;i<d;i++) c[i]=0;
for(i=0;i<128;i++) c[i]=0;
}
f=-1;
for (i=128;i>=0;i--)
if (z[i]!=0) {r=i;break;}
v=r-u;
if (b>0) { for (i=0;i<r;i++) if (z[i]==0) f=i; else break;
for (i=r;i>u;i--) printf("%d",z[i]) ; if (f!=v) printf(".");
for (i=u;i>f;i--) printf("%d",z[i]);}
else for (i=r;i>=0;i--) printf("%d",z[i]); printf("\n");}
return 0;
}