skfjh

 

F

题目:https://vjudge.net/contest/436484#problem/F

快速幂板子直接上

#include<stdio.h>
const int N=1e9+7;
long long kuaisu(long long x,long long y)
{
    long long z=1;
    while(y)
    {
        if(y%2==1) z=z*x%N;
        x=(x*x)%N;
        y=y/2;
    }
    return z;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        long long n,m;
        scanf("%lld%lld",&n,&m);
        printf("%lld\n",kuaisu(n,m));
    }
    return 0;
}

 

posted on 2021-05-04 18:17  skfjh  阅读(81)  评论(0编辑  收藏  举报

导航