题意
思路
二进制转化+快速幂
代码
class Solution {
public:
int superPow(int a, vector<int>& b) {
string tmp;
int l = 0;
while (l < b.size()) {
int x = 0;
for (int i = l; i < b.size(); i++)
{
int y = x * 10 + b[i];
x = y % 2;
b[i] = y / 2;
if (b[i] == 0 && i == l)
l++;
}
tmp += (x ? "1" : "0");
}
//cout << tmp << endl;
long ans = 1;
long k = a % 1337;
for (auto &index : tmp) {
if (index == '1')
ans = ans * k % 1337;
k = (k * k) % 1337;
}
return ans;
}
};
1354

被折叠的 条评论
为什么被折叠?



