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 wuzhudexiaocao at 2008-08-26 02:29:28 on Problem 1730
#include<iostream>
#include<math.h>
using namespace std;

int power(int a,int b)
{
	int i;
	int sum=1;
	for(i=0;i<b;i++)
	{
		sum=sum*a;
	}
	return sum;
}
int main()
{
	double n;
	int i,j,k;
	while(cin>>n&&n!=0)
	{
		if(n>0)
		{
			for(i=32;i>=1;i--)
			{
				j=(int)pow(n,1.0/i);
				if(n==power(j,i))
				{
					k=i;
					break;
				}
			}
			cout<<k<<endl;
		}
		else
		{
			n=-n;
			for(i=32;i>=1;i--)
			{
				j=(int)pow(n,1.0/i);
				if(n==power(j,i))
				{
					k=i;
					if(k%2==0)continue;
					break;
				}
			}
			 cout<<k<<endl;
		}
	}
	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