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

Re:我的哪里有问题呢.......(给出的数据通过)但是还是 wa

Posted by stoundmire at 2007-03-31 09:14:45 on Problem 3100
In Reply To:我的哪里有问题呢.......(给出的数据通过)但是还是 wa Posted by:00liuqing at 2007-03-04 20:16:09
> #include<iostream>
> using namespace std;
> int f(int& ml,int &m,int b,int n);
> int pow(int a,int n);
> int main()
> {
> 	int b,n,a,ml,m,k;
> 	cin>>b>>n;
> 	while(b&&n)
> 	{
>         ml=1;m=b;
> 		k=f(ml,m,b,n);
> 		if(k)
> 			cout<<k<<endl;
> 		else if(pow(ml,n)+pow(m,n)>=2*b)
> 			cout<<ml<<endl;
> 		else cout<<m<<endl;
> 		cin>>b>>n;
>     } 
> }
> int f(int& ml,int &m,int b,int n)
> {
>     //cout<<ml<<" "<<m<<" ";
> 	int res=0,t=1;
>     	for(int i=n;i&&t<=b;i--)
> 		t*=(ml+m)/2;//cout<<" "<<t<<endl; 
> 	if(ml==m||ml+1==m)
> 		return 0;
> 	if(t==b)
> 		return (ml+m)/2;
> 	else if(t>b)
> 	{
> 		m=(ml+m)/2;
> 		res=f(ml,m,b,n);
> 	}
> 	else if(t<b)
> 	{
> 		ml=(ml+m)/2;
> 		res=f(ml,m,b,n);
> 	}
> 	return res;
> }
> int pow(int a,int n)
> {
> 	int t=1;
> 	for(int i=n;i;i--)
> 		t*=a;
> 	return t;
> }

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