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

用pow()很耗时间吗?

Posted by xcl119xcl at 2007-07-28 10:19:44 on Problem 1543
//同样的代码,我如果用pow就超时,不用就ac,纳闷了???
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int max;
	cin>>max;
	int now=6;
	while(now<=max)
	{
		for(int i=2;i<now;i++)
		{
			for(int j=i;j<now;j++)
			{
				for(int k=j;k<now;k++)
				{
					if(now*now*now==(i*i*i+j*j*j+k*k*k))
				//	if(pow(now,3)==(pow(i,3)+pow(j,3)+pow(k,3)))
						cout<<"Cube = "<<now<<", Triple = ("<<i<<","<<j<<","<<k<<")"<<endl;
				}
			}
		}
		now++;
	}
	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