sicily 1394. Root of the Problem

#include<iostream>
#include
<cmath>
#include
<cstdlib>
using namespace std;
int main()
{
int b,n,s,t,s1,t1;
while(cin>>b>>n&&b)
{
s
=floor(pow(double(b),1.0/n));
t
=ceil(pow(double(b),1.0/n));
if(s==t)
cout
<<s<<endl;
else
{
s1
=pow(double(s),double(n));
t1
=pow(double(t),double(n));
if(abs(s1-b)<abs(t1-b))
cout
<<s<<endl;
else
cout
<<t<<endl;
}
}
return 0;
}

posted on 2011-07-05 02:06  sysu_mjc  阅读(162)  评论(0编辑  收藏  举报

导航