Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

站在巨人的肩膀上还是比较容易实现的,啥也不说了,粘代码吧!

Posted by wzp_moon at 2015-08-12 17:07:51 on Problem 3100
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator