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:我的推导过程

Posted by dart at 2007-10-06 03:55:33 on Problem 1183
In Reply To:我的推导过程 Posted by:xuguangshengqq at 2007-07-19 22:05:39
看看我的推导怎么样?不过submit 后老是说答案错误...郁闷啊.....
首先同理有m=a+b, a = (bc-1) / (b+c) 则 bc=a*m+1;
则b,c是方程x^2-m*x+(a*m+1)=0的两个根,则sqrt(m^2-4(a*m+1))存在且为一个正整数,
由此可得一个while循环判断(m^2-4(a*m+1))是不是一个平方数,不是的话再使m++;题目保证肯定有解,加上一些优化手段,实际演算非常快,可郁闷得是答案错误,真搞不懂,我新手,希望大家指点下.....附下我的程序.....

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	long int a,m,n,p;
	int flags=1;
step:	cin>>a;
		if(!(a>=1&&a<=60000)) goto step;
	m=4*a+1;
	p=m*m-4*(a*m+1);
	long int q=sqrt(p);
	while(p!=q*q)
	{
		m++;
		p=m*m-4*(a*m+1);
	    q= sqrt(p);
	}
        cout<<m;
	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