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

poj的AC,0MS,UVA的却TLE

Posted by qiueji at 2011-02-16 00:27:23 on Problem 1289
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long int m,n;
	while(cin>>m>>n && m+n)
	{
		long long int i,j;
		for(j=31;j>=1;j--)
		{
			if(n==1) {j=1;break;}
			double t=pow(n*1.0,1.0/j*1.0);
			//cout<<t<<endl;
			if(pow((int(t+0.5))*1.0,j*1.0)==n) {j=int(t+0.5);break;}
		}
		//cout<<"j="<<j<<endl;
		long long int temp=m;
		long long int high=0,cat=1,catall=1;
		while(temp!=1)
		{
			high+=temp*cat;
			cat*=j;
			catall+=cat;
			temp/=(j+1);
		}
		high+=n;
		cout<<catall-cat<<" "<<high<<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