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

wa了无数次,忍无可忍后只好枚举了

Posted by Icanmey at 2008-11-10 16:31:10 on Problem 3100
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	double b,n;
	while(cin>>b>>n)
	{
		int i;
		if(b==0&&n==0)
			break;
		double temp=b;
		int record;
		for(i=1;pow(i,n)<=b+temp;i++)
		{
			if(abs(pow(i,n)-b)<temp)
			{
				temp=abs(pow(i,n)-b);
				record=i;
			}
		}
		cout<<record<<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