扩展欧几里得算法 int exgcd(int a,int b,int &x,int &y) { if(b==0) return x=1,y=0,a ; int d=exgcd(b,a%b,y,x) ; return y-=a/b*x,d ; } 龟速乘 LL mul(LL a,LL b,LL mod) { a=(a%mod+mod)%mod ; b=(b%mod+mod)%mod ; LL tmp=a*b-(LL)((long double)a/mod*b+1e-9)*mod ; return tmp<0?tmp+mod:tmp ; } 整除分块 for...