1 条题解
-
1I_am_Chinese_qwq LV 8 MOD @ 2020-03-04 18:39:04
模板题。一个快速幂。
\[ a^b = (a^{b/2})^2 \]
#include <cstdio> #include <iostream> #include <cmath> #include <cstring> #include <algorithm> #define For(i,j,k) for(int i=j;i<=(k);++i) using namespace std; typedef long long ll; inline int read(){ int x=0,w=0;char c=getchar(); for(;c<'0'||c>'9';w^=c=='-',c=getchar()); for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+(c^48),c=getchar()); return w?-x:x; } int qpow(int n,int m,int k){ //n^m%k if(m==0) return 1; long long ans=qpow(n,m/2,k)%k; if(m&1) return (int)(ans*ans%k*n%k); return (int)(ans*ans%k); } int main(){ //freopen(".in","r",stdin); //freopen(".out","w",stdout); //ios::sync_with_stdio(false); //cin.tie(NULL); //cout.tie(NULL); int a,b;cin>>a>>b; cout<<qpow(a,b,2580000); return 0; }
- 1