BigNum a, b, c, d;

char out[60005];

int main ()
  {
char in[50];
int flag;
int n;
int i, j;

while ( scanf ( "%s%d", &in, &n ) != EOF )
 {
int len = strlen ( in );
flag = 0;
for ( i=0; i<len; i++ )
 {
if ( in[i] == '.' )
 {
flag = ( len - i - 1 ) * n;
for ( j=i+1; j<len; j++ )
 {
in[j-1] = in[j];
}
in[j] = in[j+1];
len --;
break;
}
}

a.set ( "1", 1 );
b.set ( in, len );
c.set ( "0", 1 );

if ( ! Cmp ( b, c ) )
 {
printf ( "0\n" );
continue;
}

while ( n != 0 )
 {
if ( n & 1 )
 {
Mul ( a, b, c );
Cpy (a, c);
}
Cpy ( d, b );
Mul ( b, d, c );
Cpy ( b, c );
n >>= 1;

}

int l;
int count = 0;
int p = 0;
b.set ( "0", 1 );
while ( Cmp ( a, b ) || count <= flag )
 {
Div ( a, 10, l );
if ( count == flag && flag )
 {
out[p++] = '.';
}
out[p++] = (char)(l + '0');
count ++;
}

out[p] = '\0';
for ( i=0; i<p-1; i++ )
 {
if ( out[i] == '0' )
 {
out[i] = 0;
}
else
 {
if ( out[i] == '.' )
 {
out[i] = 0;
}
break;
}
}

if ( p>1 && out[p-1] == '0' )
 {
p --;
}
for ( i=p-1; out[i]!=0; i-- )
 {
printf ( "%c", out[i] );
}
printf ( "\n" );

}
return 0;
}
|
|
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
---|
24 | 25 | 26 | 27 | 28 | 29 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 1 | 2 | 3 | 4 | 5 |
|
公告
决定从线程开始!!
常用链接
留言簿(6)
随笔档案
搜索
最新评论

阅读排行榜
评论排行榜
|
|