| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
那位帮忙看看为什么wrong answer,sample数据都没错啊。多谢了!!我是头一次来,请多关照#include<stdio.h>
#include <string.h>
int main(int argc,char ** argv)
{
char a[6],r[5], result[125],temp[5][125];
int n,m,d,i,j,k,l,sum;
scanf("%c%c%c%c%c%c %d",
&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],
&n);
for(i = 0;(i < 6)&&(a[i] == '0'||a[i] == '.');i++ );
for(j = 5;(j >= 0)&&(a[j] == '0'||a[j] == '.');j-- );
for(k = 0;a[k] != '.';k++);
if (i>j) {
printf("0\n");
return 0;
};
for(m = 0,d = j;d >= i ;d--,m++)
if((r[m] = a[d]) == '.')
m--;
d = k - j;
for( i = m-1;i>=0;i--)
r[i]-='0';
for(i=0;i<125;i++)
result[i] = 0;
memcpy(result,r,m);
for(l=n;l>1;l--)
{
for(i=0;i<125;i++)
for(j = 0;j < m;j++)
temp[j][i] = 0;
for(i = 124;result[i] == 0;i--);
for(j = 0;j < m;j++)
for(k = 0;k <= i;k++)
{
temp[j][k+j] += result[k]*r[j];
temp[j][k+j+1] += (char)(temp[j][k+j]/10);
temp[j][k+j] %= 10;
};
for(k=0;k<125;k++)
result[k] = 0;
for(k = 0;k <= i+m;k++)
{
sum = 0;
for(j = 0;j < m;j++)
sum += temp[j][k];
result[k] += sum;
result[k+1] += (char)(result[k]/10);
result[k] %= 10;
};
};
for(i = 124;result[i] == 0;i--);
if((i+d*n+1) <= 0)
{
printf(".");
for( k = i+d*n+1;k<0;k++)
printf("0");
for(k = i;k >= 0;k--)
printf("%d",result[k]);
}else for(k = i;k >= 0;k--)
{
if(k+d*n+1 == 0)
printf(".");
printf("%d",result[k]);
};
printf("\n");
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator