记得取模时对答案的处理
#include<bits/stdc++.h> #define ll long long using namespace std; ; ll qpow(ll a,ll b) { ll ans=; while(b) { )ans=ans*a%M; a=a*a%M,b>>=; } return ans; } ll m,n,ans; int main() { cin>>m>>n; ) ans=; ,n-))%M; cout<<(ans+M)%M<<endl; ; }
记得取模时对答案的处理
#include<bits/stdc++.h> #define ll long long using namespace std; ; ll qpow(ll a,ll b) { ll ans=; while(b) { )ans=ans*a%M; a=a*a%M,b>>=; } return ans; } ll m,n,ans; int main() { cin>>m>>n; ) ans=; ,n-))%M; cout<<(ans+M)%M<<endl; ; }