#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int x, y;
cin >> x >> y;
int result = 1;
for(int i=0; i<y; i++)
result = result * x % 1000;
cout << result << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
当M, N很大时, M的N次方无法用基本的数据类型表示...分析可以发现, 乘积的最后三位只与乘数和被乘数的最后三位有关, 而与高位无关, 所以每次将乘积结果对1000取模即可...
求M的N次方的后三位
最新推荐文章于 2022-11-17 19:50:26 发布