TEST 页面

/********************************************************************************
    * @author: Nondifferentiable
    * @date: 2023/9/27 13:36
    * @creed: Talk is cheap,show me the code
********************************************************************************/

#include<bits/stdc++.h>

using namespace std;
#pragma GCC(3)
typedef long long ll;
#define endl '\n'
#define SQR(i) fixed<<setprecision(i)
#define inf 0x3f3f3f3f//int max
#define inf_max 0x3f3f3f3f3f3f3f3f//long long max
#define rep(i, a, n) for (int i=a;i<=n;i++)
#define per(i, n, a) for (int i=n;i>=a;i--)
#define pb push_back
#define all(x) x.begin(),x.end()
//#define int long long

typedef std::pair<int, int> PII;
constexpr int N = 2e5 + 5;
constexpr int mod = 1e9 + 7;
//constexpr int mod = 1004535809469762049;

void Yes() {
	std::cout << "YES" << endl;
	return;
}

void No() {
	std::cout << "NO" << endl;
	return;
}

template<typename T>
void out(T x) { std::cout << x << "\n"; }

struct reader {
	template<typename Type>
	reader &operator>>(Type &ret) {
		int f = 1;
		ret = 0;
		char ch = getchar();
		for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -f;
		for (; isdigit(ch); ch = getchar()) ret = (ret * 10) + ch - '0';
		ret *= f;
		return *this;
	}
} fin;

/*-----------------------------------------------------------------------------------------------*/
string bigMultiply(string a,string b){
	//开辟数组value
	vector<int> value(a.size()+ b.size(),0);
	//b取出1位分别与a的每一位相乘
	for(int bIndex = b.size() - 1;bIndex >= 0;bIndex--){
		int curB = b[bIndex] - '0';
		int valueIndex = value.size() - (b.size() - bIndex); //从b这一位开始填充
		for(int aIndex = a.size() - 1;aIndex >= 0;aIndex--){
			int curA = a[aIndex] - '0';
			value[valueIndex] += curA * curB;
			valueIndex--;
		}
	}
	//处理进位
	int jinWei = 0;
	for(int i = value.size() - 1;i >= 0;i--){
		int curValue =(value[i] + jinWei) % 10;
		jinWei = (value[i] + jinWei) / 10;
		value[i] = curValue;
	}
	string ans = "";
	bool isZero = true;
	for(int i = 0;i < value.size();i++){
		if(value[i] != 0){
			isZero = false;
		}
		if(isZero == false){
			ans = ans + to_string(value[i]);
		}
	}
	return ans;

}

string qpow(string a, int n) {
	string ans = "1";
	while (n) {
		if (n & 1)ans = bigMultiply(ans,a);
		n >>= 1;
		a =bigMultiply(a,a);
	}
	return ans;
}
string a;	
int n;
void solve() {

	cout<<qpow(a,n)<<endl;

}

signed main() {
	//std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	int _ = 1;
	//cin >> _;
	while (cin >> a>>n)
		solve();
}
posted @ 2023-09-27 15:57  Nondifferent  阅读(8)  评论(1编辑  收藏  举报