标签:ace using ring a* bsp 乘法 pre mes can
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> #define ll long long using namespace std; ll n,p; int main() { scanf("%lld%lld",&n,&p); ll a=n,ans=1,b=p-2; while(b) { if(b&1) ans=ans*a%p; a=a*a%p; b=b>>1; } printf("%lld",ans); return 0; }
标签:ace using ring a* bsp 乘法 pre mes can
原文地址:https://www.cnblogs.com/water-radish/p/9280545.html