| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
很弱的问题,帮忙看一下#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator