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 |
站在巨人的肩膀上还是比较容易实现的,啥也不说了,粘代码吧!#include <stdio.h> #include <math.h> int main(void) { long a,b,n; long c,tmp1,tmp2; /*注意以下输入终止的写法*/ while(scanf("%ld %ld",&b,&n),b != 0 && n != 0) { c =(long)pow(b,1.0 / n); tmp1 = b - pow((double)c,n);/*重载需要指明参数确定类型*/ tmp2 = pow((double)(c + 1),n) - b; if (tmp1 < tmp2) { printf("%d\n",c); } else { printf("%d\n",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