【转】http://blog.youkuaiyun.com/zxy_snow/article/details/6036148
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
int main(void)
{
double b,n,temp;
while( cin >> b >> n && b && n )
{
temp = pow(b,1/n);
int x = (int)temp;
int y = (int)(temp+0.5);
if( b - pow(x,n) > pow(y,n) - b )
cout << y << endl;
else
cout << x << endl;
}
return 0;
}
求解带余数的幂运算问题
本文提供了一个C++程序,用于解决输入两个正整数b和n后,计算b的n次方后的余数。程序通过利用数学运算和条件判断实现,确保了计算的准确性和效率。

被折叠的 条评论
为什么被折叠?



