#include <iostream>
#define MAX 1000
using namespace std;
//小整数的整数次方
/*
int PowerWithUnsignedExponent(int base, int exponent)
{
if(exponent == 0)
return 1;
if(exponent == 1)
return base;
int result = PowerWithUnsignedExponent(base, exponent >> 1);
result *= result;
if(exponent & 0x1 == 1)
result *= base;
return result;
}
*/
//利用数组转换大整数,每位先乘以2,再处理进位
int main()
{
int base;
cin >> base;
int exponent;
cin >> exponent;
int *result = new int[MAX + 10]();
result[0] = 1;
int nHighestPos = 0;
for(int i = 0; i < exponent; ++i)
{
//按位乘以base
for(int j = 0; j < exponent; ++j)
{
result[j] *= base;
}
//处理进位
for(int k = 0; k < exponent; ++k)
{
if(result[k] >= 10)
{
result[k + 1] += result[k] / 10;
result[k] = result[k] % 10;
}
if(result[k])
nHighestPos = k;
}
}
for(int i = nHighestPos; 0 <= i; --i)
cout << result[i];
delete [] result;
return 0;
}
0 - 9的100——1000次方
最新推荐文章于 2025-01-09 14:58:48 发布