#include <iostream>
#include <string>
#include <vector>
using namespace std;
class LiQiang
{
private:
int dot;
vector<char> m_value;
public:
LiQiang()
{
dot = 0;
}
LiQiang(char *str)
{
dot = 0;
int len = strlen(str);
for (int i = len - 1; i >= 0; i--)
{
if ('.' == str[i])
{
dot = len - i - 1;
continue;
}
m_value.push_back(str[i]);
}
vector<char>::iterator it = m_value.begin();
while (*it == '0')
{
if (!dot)
break;
m_value.erase(it);
dot--;
it = m_value.begin();
}
vector<char>::reverse_iterator itor = m_value.rbegin();
while (*itor == '0')
{
m_value.pop_back();
itor = m_value.rbegin();
}
if (dot == m_value.size())
m_value.push_back('0');
}
LiQiang * operator = (LiQiang * tmp)
{
dot = tmp->dot;
m_value.clear();
m_value.assign(tmp->m_value.begin(), tmp->m_value.end());
delete tmp;
return this;
}
LiQiang * operator * (LiQiang & tmp)
{
LiQiang *res = new LiQiang;
res->dot = tmp.dot + dot;
int count = 0;
int bit = 0;
for (int i = 0; i < m_value.size(); i++)
{
count = i;
bit = 0;
for (int j = 0; j < tmp.m_value.size(); j++)
{
if (count < res->m_value.size())
{
int value = ((m_value[i] - '0') * (tmp.m_value[j] - '0') + bit + res->m_value[count] - '0')
% 10 + '0';
bit = ((m_value[i] - '0') * (tmp.m_value[j] - '0') + bit + res->m_value[count] - '0')
/ 10;
res->m_value[count] = value;
}else
{
int value = ((m_value[i] - '0') * (tmp.m_value[j] - '0') + bit)
% 10 + '0';
bit = ((m_value[i] - '0') * (tmp.m_value[j] - '0') + bit)
/ 10;
res->m_value.push_back(value);
}
count++;
}
if (bit)
{
if (count < res->m_value.size())
{
res->m_value[count] += bit;
} else {
res->m_value.push_back(bit + '0');
}
}
}
vector<char>::iterator itor = res->m_value.begin();
while (*itor == '0')
{
if (!dot)
break;
res->m_value.erase(itor);
res->dot--;
itor = res->m_value.begin();
}
return res;
}
friend ostream & operator << (ostream & os, LiQiang & tmp);
};
ostream & operator << (ostream & os, LiQiang & tmp)
{
for (int i = tmp.m_value.size() - 1; i >= 0; i--)
{
if ( tmp.m_value.size() - i - 1 == tmp.m_value.size() - tmp.dot)
{
cout << '.';
}
if (i == tmp.m_value.size() - 1 && tmp.m_value[i] == '0')
continue;
cout << tmp.m_value[i];
}
cout << endl;
return os;
}
int main()
{
char str[500];
int num;
vector<LiQiang> res_tmp;
while (cin >> str >> num)
{
LiQiang x(str);
LiQiang res(str);
for (int i = 0; i < num - 1; i++)
{
res = res * x;
}
res_tmp.push_back(res);
}
for (int i = 0; i < res_tmp.size(); i++)
{
cout << res_tmp[i];
}
system("PAUSE");
return 0;
}
#include <string>
#include <vector>
using namespace std;
class LiQiang
{
private:
int dot;
vector<char> m_value;
public:
LiQiang()
{
dot = 0;
}
LiQiang(char *str)
{
dot = 0;
int len = strlen(str);
for (int i = len - 1; i >= 0; i--)
{
if ('.' == str[i])
{
dot = len - i - 1;
continue;
}
m_value.push_back(str[i]);
}
vector<char>::iterator it = m_value.begin();
while (*it == '0')
{
if (!dot)
break;
m_value.erase(it);
dot--;
it = m_value.begin();
}
vector<char>::reverse_iterator itor = m_value.rbegin();
while (*itor == '0')
{
m_value.pop_back();
itor = m_value.rbegin();
}
if (dot == m_value.size())
m_value.push_back('0');
}
LiQiang * operator = (LiQiang * tmp)
{
dot = tmp->dot;
m_value.clear();
m_value.assign(tmp->m_value.begin(), tmp->m_value.end());
delete tmp;
return this;
}
LiQiang * operator * (LiQiang & tmp)
{
LiQiang *res = new LiQiang;
res->dot = tmp.dot + dot;
int count = 0;
int bit = 0;
for (int i = 0; i < m_value.size(); i++)
{
count = i;
bit = 0;
for (int j = 0; j < tmp.m_value.size(); j++)
{
if (count < res->m_value.size())
{
int value = ((m_value[i] - '0') * (tmp.m_value[j] - '0') + bit + res->m_value[count] - '0')
% 10 + '0';
bit = ((m_value[i] - '0') * (tmp.m_value[j] - '0') + bit + res->m_value[count] - '0')
/ 10;
res->m_value[count] = value;
}else
{
int value = ((m_value[i] - '0') * (tmp.m_value[j] - '0') + bit)
% 10 + '0';
bit = ((m_value[i] - '0') * (tmp.m_value[j] - '0') + bit)
/ 10;
res->m_value.push_back(value);
}
count++;
}
if (bit)
{
if (count < res->m_value.size())
{
res->m_value[count] += bit;
} else {
res->m_value.push_back(bit + '0');
}
}
}
vector<char>::iterator itor = res->m_value.begin();
while (*itor == '0')
{
if (!dot)
break;
res->m_value.erase(itor);
res->dot--;
itor = res->m_value.begin();
}
return res;
}
friend ostream & operator << (ostream & os, LiQiang & tmp);
};
ostream & operator << (ostream & os, LiQiang & tmp)
{
for (int i = tmp.m_value.size() - 1; i >= 0; i--)
{
if ( tmp.m_value.size() - i - 1 == tmp.m_value.size() - tmp.dot)
{
cout << '.';
}
if (i == tmp.m_value.size() - 1 && tmp.m_value[i] == '0')
continue;
cout << tmp.m_value[i];
}
cout << endl;
return os;
}
int main()
{
char str[500];
int num;
vector<LiQiang> res_tmp;
while (cin >> str >> num)
{
LiQiang x(str);
LiQiang res(str);
for (int i = 0; i < num - 1; i++)
{
res = res * x;
}
res_tmp.push_back(res);
}
for (int i = 0; i < res_tmp.size(); i++)
{
cout << res_tmp[i];
}
system("PAUSE");
return 0;
}