没分 代码要全
DO IT YOURSELF !
ZZ PowerMod(const ZZ& a, const ZZ& e, const ZZ& n) { if (e == 0) return to_ZZ(1); long k = NumBits(e); ZZ res; res = 1; for (long i = k-1; i >= 0; i--) { res = (res*res) % n; if (bit(e, i) == 1) res = (res*a) % n; } if (e < 0) return InvMod(res, n); else return res; }