#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MOD = 1000000007;
LL quick_pow(LL a,LL b)
{
a = a % MOD;
LL ans = 1;
while(b)
{
if(b & 1)ans = ans * a % MOD;//如果是1在这位上,就乘
b >>= 1; //进位
a = a * a % MOD;//乘以一位的2
}
return ans;
}
int main()
{
LL a,b;
int n;
scanf("%d",&n);
while(n--)
{
scanf("%I64d%I64d",&a,&b);
printf("%I64d\n",quick_pow(a,b));
}
return 0;
}
快速幂
最新推荐文章于 2025-04-13 23:00:00 发布