// Solution by OUSAA#include <stdio.h>#include <string.h>void add(int* a1,int* a2,int* result){ int i; int temp; for (i=0,temp=0;i<51;++i) { result[i]=temp; temp=a1[i]+a2[i]; result[i]+=temp%10; temp/=10; } result[n]=temp;}void multiply(int* m1,int* m2,int* result){ int i,j; int up; int mid[103],step[103]; for (i=0;i<51;++i) { int temp=m2[i]; if (temp==0) continue; memset(mid,0,sizeof(mid)); for (j=0,up=0;j<51;++j) { mid[j+i]=up+m1[j]*temp; up=mid[j+i]/10; mid[j+i]%=10; } mid[n1+i]=up; add(mid,result,step,n1+i); memcpy(result,step,51*sizeof(int)); }}void exponential(int* m1,int ex,int* result){ int i; for (i=0;i<ex;++i) { multiply(m1,m1,result); memcpy(m1,result,51*sizeof(int)); }}int main(){ char num[7]; int d[51]; int res[51]; int ex; int i,k,dot,pos; int forward; while(scanf("%s %d",num,&ex)) { memset(d,0,sizeof(d)); memset(res,0,sizeof(res)); for (i=0,dot=5,pos=4;i<6;++i) { if (num[i]=='.') { dot=i; continue; } d[pos--]=num[i]-'0'; } forward=(5-dot)*ex; exponential(d,ex,res); k=50; while (res[k]==0) --i; for (i=k;i>=forward;--i) putchar(res[i]+'0'); if (forward!=0) { putchar('.'); for (i=forward-1;i>=0;--i) putchar(res[i]+'0'); } putchar('\n'); } return 0;}
#include <iostream>using namespace std;const int MAX = 1000;int length(int num){ int k = 0; while(num/10 != 0) { k++; num /= 10; } return k+1; }void Multiply(int result[], int& resultlen, int digit[], int k){ int i; int j; int len; int re[MAX]; for (i = 0; i < MAX; i++) re[i] = 0; for (i = 0; i < k; i++) for (j = 0; j < resultlen; j++) { re[i+j] += result[j] * digit[i]; re[i+j+1] += re[i+j] / 10; re[i+j] %= 10; } len = resultlen + k; if (re[len-1] == 0) len--; resultlen = len; for (i = 0; i < len; i++) result[i] = re[i];} int main(){ double r; int n; int dot; int i; int j; int k; int m; int digit[MAX]; int result[MAX]; int resultlen; bool flag = true; while (cin >> r >> n) { i = length((int)r); if (i == 1) { dot = 4; r = r * 10000; } else { dot = 3; r = r * 1000; } long int number = (long int)r; dot = dot * n; if (number == 0) { cout << "0" <<endl; continue; } for (i = 0; i < MAX; i++) { digit[i] = 0; result[i] = 0; } k = length(number); resultlen = k; for (i = 0; i < k; i++) { digit[i] = result[i] = number % 10; number /= 10; } for (i = 0; i < n-1; i++) Multiply(result, resultlen, digit, k); i = 0; while (i < dot) { if (result[i] != 0) break; i++; } if (i == dot) flag = false; else { flag = true; m = i; } if (resultlen > dot) { for (i = resultlen - 1; i >= dot; i--) cout << result[i]; if (flag) { cout << "." ; for (i = dot - 1; i >= m; i--) cout << result[i]; } } else { if (flag) { cout << "." ; for (i = dot - 1; i >= m; i--) cout << result[i]; } } cout << endl; } return 0;}