快速幂模板
数论模板第二弹(我太弱啦!
据说这个版本的快速幂常数小
#pragma GCC optimize("O2")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<limits.h>
#include<ctime>
#define N 100001
typedef long long ll;
const int inf=0x3fffffff;
const int maxn=2017;
using namespace std;
inline int read()
{
int f=1,x=0;char ch=getchar();
while(ch>'9'|ch<'0')
{
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch<='9'&&ch>='0')
{
x=(x<<3)+(x<<1)+ch-'0';
ch=getchar();
}
return f*x;
}
ll qpow(ll a,ll b,ll c)
{
ll k=1;
while(b)
{
if(b&1)
k=(k*a)%c;
a=(a*a)%c;
b>>=1;
}
return k;
}
int main()
{
int n=read(),m=read(),k=read();
printf("%ld",qpow(n,m,k));
}
就让我永远不在这里写下什么有意义的话——by 吉林神犇 alone_wolf

浙公网安备 33010602011771号