#include <stdlib.h>
#include <iostream>
#include "oj.h"
using namespace std;
//思路:每次相乘,仅保留积的最后三位
unsigned int GetLastThreeNumOfResult (unsigned int m, unsigned int n)
{
unsigned int result = m %1000;
for (int i =1; i < n ;++i)
{
result = (result*m)%1000;
}
return result;
}
int main()
{
int m,n;
while (cin>>m>>n)
{
cout<<GetLastThreeNumOfResult(m,n)<<endl;
}
return 0;
}
求M的N次方的最后三位
最新推荐文章于 2021-05-19 03:43:15 发布