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

why did I got WA?(code attached)

Posted by anonym11 at 2004-10-08 17:53:31 on Problem 1730
#include<iostream>
#include<math.h>
using namespace std;

const double e = 0.69314718055994530941723212145818;

int main()
{
	double n;
	int s,i,temp;
	while(1){
		cin >> n;
		if(!n)
			break;
		if(n > 0)
		{
			if(n==1)
			{
				cout << 1 << endl;
				break;
			}
			s = log(n)/e;
			for(i = s;i > 0;i --)
			{
				temp = (int)pow(n,1/(double)i);
				if(pow((double)temp,(double)i) == n)
				{
					cout << i << endl;
					break;
				}
			}	
		}
		else
		{
			n = -n;
			s = log(n)/e;
			for(i = s;i > 0;i --)
				if(i % 2)
				{
					temp = (int)pow(n,1/(double)i);
					if(pow((double)temp,(double)i) == n)
					{
						cout << i << endl;
						break;
					}
				}
		}
	}
	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