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 Eli_love at 2009-06-07 14:02:25 on Problem 3100
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int b,n,i,min1=1;
	double cha[20],min,sun[20];
	while(cin>>b>>n)
	{
		if(b==0&&n==0) break;
		for(i=1;i<=16;i++)
		{
		sun[i]= pow(double (i),double (n));
        cha[i]=abs(sun[i]-b);
		}
	     min=cha[1];
	    for(i=2;i<=16;i++)
            if(cha[i]<min) { min=cha[i];min1=i;}
	    cout<<min1<<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