您的位置:首页 > 其它

zoj 2818 || poj 3100 Root of the Problem(水! = =)

2010-11-25 23:15 435 查看
如今 找水题也是门技术。。。



给你B N 求出 最接近B的N次方根的整数。。。



#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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: