| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
此想法代码In Reply To:硬开根号,然后判断相邻的的两个整数哪个的n次方离b最近。 Posted by:lulyon at 2011-03-14 00:44:20 #include <stdio.h>
#include <math.h>
int main()
{
int a,b;
double c;
while(scanf("%d%d",&a,&b)&&a!=0)
{
c=pow(a,1.0/b);
if(a-pow((int)c,b)<pow((int)(c+1),b)-a) printf("%d\n",(int)c);
else printf("%d\n",(int)c+1);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator