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

很弱的问题,帮忙看一下

Posted by hangsailor at 2006-10-23 19:56:33 on Problem 1183
#include<iostream>
#include<cmath>

using namespace std;

void main()
{
	int a,t,temp=0,tempnum=0;
	while(cin>>a)
	{for(t=1;;t++)
	{
		if((t*t-4*a*t-4)>=0)
		{
			tempnum=t*t-4*a*t-4;
			temp=(int)sqrt(tempnum);
			if((temp+1)*(temp+1)==tempnum || temp*temp==tempnum)
			{
				cout<<t;
				break;
			}
		}
	}
	}
}//设a,b之和为t,则有数学表达式t*t-4*a*t-4是一个完全平方数,以上有什么问题?

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