打开程序后输入B,n,k,即可得到B进制下n的k次方(5000位高精度),求各位大佬勿喷!!!
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
const int N=5000+1;
const int M=5000;
void slowsay(string x);
int a[N];
bool check[N];
int main()
{
int B,k;
int n;
slowsay("2 <= B <= 36 , DON'T INPUT CASUALLY , OR THE SYSTEM WILL ERROR!!!\n\n");
cin>>B>>n>>k;
if(B<2||B>36){
slowsay("\nWHAT ARE YOU DOING ?\n");
return 0;
}
a[0]=1;
check[0]=true;
int x=0;
int True=0;
int la=M,checka=M;
for(int i=1;i<=k;i++){
while(check[True]){
a[True]*=n;
check[True]=true;
True++;
}
for(int j=0;j<N;j++){
if(a[j]>=B){
x=a[j]/B;
a[j]%=B;
a[j+1]+=x;
}
}
while(a[checka]==0){
checka--;
}
for(int j=0;j<=checka;j++){
check[j]=true;
}
checka=M;
True=0;
}
while(a[la]==0){
la--;
}
slowsay("\nIn base ");
cout<<B;
Sleep(20);
slowsay(" , ");
cout<<n;
Sleep(20);
slowsay(" ^ ");
cout<<k;
Sleep(20);
slowsay(" is : \n\n");
for(int i=la;i>=0;i--){
if(a[i]<10){
cout<<a[i];
Sleep(1);
}
else{
char l=a[i]-10+'A';
cout<<l;
Sleep(1);
}
}
slowsay("\n\n");
return 0;
}
void slowsay(string x){
for(int i=0;i<x.size();i++){
cout<<x[i];
Sleep(20);
}
}