格式:
2 3
1.2 2
输出:
8
1.44
代码:
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
using namespace std;
int main()
{
string s;
short n;
while(cin>>s>>n) {
double r = 1;
double d = atof(s.c_str());
if (n == 0 || d == 0) {
cout<<1<<endl;
continue;
}
short i = 0;
double c = 1;
while (n) {
if (i == 0) {
c = d;
}
else {
c *= c;
}
if (n%2) {
r *= c;
}
//printf("n:%x,\tr=%d, \tc=%d\n",n,r,c);
n >>= 1;
i++;
}
//cout<<r<<endl;
printf("%f\n",r);
}
return 0;
}