Turtle speed ride is long long * long long but not explode will explode after% MOD when used to solve long long * long long% MOD
1 inline LL Slow(LL L,LL R,LL M) { 2 L=(L%M+M)%M; 3 R=(R%M+M)%M;//我也不知道为什么 4 LL Res=L*R-(LL)((LD)L/M*R+1e-8)*M; 5 return Res<0 ? Res+M : Res; 6 }
Quick ride , and take the turtle speed the same way, just by changing the form of fast power
Code:
1 long long quick_mul(long long x,long long y,long long mod) 2 { 3 long long ans=0; 4 while(y!=0){ 5 if(y&1==1)ans+=x,ans%=mod; 6 x=x+x,x%=mod; 7 y>>=1; 8 } 9 return ans; 10 }