#include<stdio.h>
#include<stdlib.h>
#define MAX 2000
typedef struct Node{
int val[MAX];//存储数字
int len, fra;//分别表示数字个数和小数部分长度
} Node;
Node CreatNode(char str[]);
Node Pow(Node A, int n);
Node Mul(Node A, Node B);
void PrintNode(Node A);
int main(void)
{
char str[MAX];
Node A, B;
int n;
while (scanf("%s%d", str, &n) == 2) //或者“!=EOF”或者“!=-1”
{
// printf("s= %s, n = %d\n", str, n);
A = CreatNode(str);
B = Pow(A, n);
PrintNode(B);
}
return 0;
}
Node CreatNode(char str[])
{
int i, n, f;
Node A;
i = n = f = 0;
while (str[i] != '.' && str[i] != '\0')//获取整数部分
{
A.val[n++] = str[i++] - '0';
}
if (str[i] == '.')
{
i++;
while (str[i] != '\0')//获取小数部分
{
f++;
A.val[n++] = str[i++] - '0';
}
}
A.len = n;
A.fra = f;
while (A.fra > 0 && A.val[A.len-1] == 0)//消除小数部分多余的后缀0
{
A.fra--;
A.len--;
}
return A;
}
Node Pow(Node A, int n)
{
Node B, C;
if (n == 1)
return A;
if (n == 0)
{
C.val[0] = C.len = 1;
C.fra = 0;
return C;
}
B = Pow(A, n/2);
C = Mul(B, B);
if (n % 2 == 1)
C = Mul(C, A);
return C;
}
Node Mul(Node A, Node B)
{
Node C;
int M[MAX] = {0};
int i, j, k, d, s;
for (d=1,i=A.len-1; i>=0; i--, d++)
{
if (A.val[i] == 0)//乘数是0就直接跳过
continue;
k = MAX - d;
for (j=B.len-1; j>=0; j--)
{
s = A.val[i] * B.val[j] + M[k]; //直接在M[k]中取进位
M[k] = s % 10;
M[--k] += s / 10; //把进位存储到M[k-1]
}
while (M[k] >= 10) //分解多位数
{
s = M[k];
M[k] = s % 10;
M[--k] = s / 10;
}
}
while (MAX-k < A.fra + B.fra) //若整数部分为0,补足小数部分的前缀0
{
M[--k] = 0;
}
while (MAX-k > A.fra + B.fra && M[k] == 0)//去除多余的前缀0
k++;
for (i=0; k<MAX; i++)//复制数字到C
C.val[i] = M[k++];
C.len = i;
C.fra = A.fra + B.fra;
while (C.fra > 0 && C.val[C.len-1] == 0)//消除小数部分多余的后缀0
{
C.fra--;
C.len--;
}
return C;
}
void PrintNode(Node A)
{
int z = A.len - A.fra;
int i;
for (i=0; i<z; i++)
printf("%d", A.val[i]);
if (z < A.len)
{
printf(".");
for ( ; i<A.len; i++)
printf("%d", A.val[i]);
}
printf("\n");
}