直接代公式。。。
ACcode:
#include<cstdio>
#include<cstring>
typedef long long LL;
const int MOD=1000000007;
int b,c;
LL a,ans,flag;
LL quick_pow(LL x,int y,int mod)
{
LL res=1;
while (y)
{
if (y&1) res*=x;
x*=x;
if (x>=mod) x%=mod,flag=1;
if (res>=mod) res%=mod,flag=1;
y>>=1;
}
if (res>=mod) res%=mod,flag=1;
return res;
}
int main()
{
while (~scanf("%lld %d%d",&a,&b,&c))
{
flag=0;
b=quick_pow((LL)b,c,MOD-1);
a=quick_pow(a,b+(MOD-1)*flag,MOD);
printf("%lld\n",a);
}
return 0;
}
本文深入探讨了快速幂运算及其模运算在编程中的应用,并通过实例展示了如何利用快速幂优化计算效率。重点讲解了快速幂算法的工作原理、实现方式以及在实际编程场景中的具体应用案例。
521

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



