溢出了
根据同余定理
计算过程中超过3位的全部可以去掉
// 代码最简单 unsigned a_pow_b_mod_1000( unsigned a, unsigned b ) { unsigned result = 1; while( b-- ) result = (result*a)%1000; return result; } // 使用快速幂 unsigned a_pow_b_mod_1000( unsigned a, unsigned b ) { unsigned result = 1; for( unsigned base=a; b; b>>=1, base=(base*base)%1000 ) if( b%2 != 0 ) result = (result*base)%1000; return result; }