#include <iostream>
#include <string>
#include <vector>
using namespace std;
class power
{
friend istream&operator>>(istream&In, power&r);
public:
string operator()(int n);
private:
vector<int> s;
int dot;
};
istream&operator>>(istream&In, power&r)
{
string tmp;
In>>tmp;
for(int i=0; i!=6; ++i)if(tmp[i]=='.')r.dot=6-i-1;
r.s.clear();
for(int i=5; i>=0; --i)if(tmp[i]!='.')r.s.push_back(tmp[i]-'0');
return(In);
}
string power::operator()(int n)
{
vector<int>answer(n*5);
answer[0]=1;
for(int i=0; i!=n; ++i)
{
vector<int>tmp(answer);
for(int j=0; j!=n*5; ++j)answer[j]=0;
for(int j=0; j!=n*5; ++j)
for(int k=0; k!=5; ++k)
answer[j+k]+=tmp[j]*s[k];
for(int j=1; j!=n*5; ++j)
{
answer[j]+=answer[j-1]/10;
answer[j-1]%=10;
}
}
string str;
str.clear();
for(int i=0; i!=n*5; ++i)str=(char)(answer[i]+'0')+str;
str.insert(n*5-dot*n, 1, '.');
while(str[0]=='0')str.erase(str.begin());
while(str[str.size()-1]=='0')str.erase(str.end()-1);
if(str[str.size()-1]=='.')str.erase(str.end()-1);
return(str);
}
int main()
{
power s;
int n;
while(cin>>s>>n)cout<<s(n)<<endl;
}
北大1001
最新推荐文章于 2020-08-01 02:56:25 发布