![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
const ll mod = 1000000007; ll mult_mod(ll a,ll b) //(a*b)%mod a,b,mod<2^63 { a %= mod; b %= mod; ll ans=0; while(b) { if(b&1) { ans=ans+a; if(ans>=mod) ans=ans-mod; } a=a<<1; if(a>=mod) a=a-mod; b=b>>1; } return ans; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
const ll mod = 1000000007; ll pow_mod(ll a,ll b) // a^b%mod { ll ans=1; a=a%mod; while(b) { if(b&1) { ans=mult_mod(ans,a); } a=mult_mod(a,a); b=b>>1; } return ans; }