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 fxzy at 2006-03-04 12:23:11 on Problem 1730
鉴于这个题很龌龊,我给出我的源码,没过的同学们直接用我的代码就行,不要浪费宝贵的时间了!!

#include <stdio.h>
#include <math.h>
#define zero 1e-6
int main()
{
	double n;
	int temp2,temp3,flag;
	int i,max;
while(1)
	{
	scanf("%lf",&n);
               max=1;
	 flag=0;
	 if(n==0) break;
      if(n<0) { flag=1;n=-n;}
  if(flag==0)
{	
	  for(i=2;i<=31;i++)
	{
		temp2=(int)floor(pow(n,1/(i*1.0)));
		temp3=(int)ceil(pow(n,1/(i*1.0)));
          if((fabs(pow(temp3,i)-n)<zero||fabs(pow(temp2,i)-n)<zero))
		     max=i;
	}
}

else {
          for(i=2;i<=31;i++)
	{
		temp2=(int)floor(pow(n,1/(i*1.0)));
		temp3=(int)ceil(pow(n,1/(i*1.0)));
          if((fabs(pow(temp3,i)-n)<zero||fabs(pow(temp2,i)-n)<zero)&&(i&1))
		     max=i;
	}
     }
  
	printf("%d\n",max);
	}
	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