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 zhdma at 2009-04-29 20:08:55 on Problem 1309
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;

int main()
{
	long n;
	cin>>n;
	while(n>=0)
	{
		if(n==0){
			cout<<"0 coconuts, no solution"<<endl;
			cin>>n;
			continue;
		}
		else{
			long x=2,people=0;
			for(x=2;x<=9;x++)
			{
				long n1=n+x-1;
				long pow_x=(long)pow((double)x,x);
				if(n1<pow_x)
				{
					break;
				}else if((n1%pow_x)==0)
				{
					n1=(long)(n1/pow_x);
					long pow_x_1=(long)pow((double)(x-1),x);
					n1=(long)(n1*pow_x_1+1);
					if((n1%x)==0 && (n1/x)>=2) people=x;
				}
			}
			if(people!=0) cout<<n<<" coconuts, "<<people<<" people and 1 monkey"<<endl;
			else cout<<n<<" coconuts, no solution"<<endl;
			cin>>n;
		}
	}
	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