Posted on 2012-04-06 14:51
C小加 閱讀(417)
評論(0) 編輯 收藏 引用 所屬分類:
模板
template<class IntType>
inline IntType ModPow(IntType m,IntType n,IntType p) //m的n次方模p
{
if(n==0) return 1;
if (n==1) return m%p;
IntType tmp=ModPow(m,n>>1,p);
return (tmp*tmp%p)*((n%2?m:1)%p)%p;
}