| ||||||||||
| 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 | |||||||||
附代码,OLE!In Reply To:不知道这个算法行不行 Posted by:Shinjikun at 2006-02-08 01:49:13 Source
Problem Id:1183 User Id:Shinjikun
Memory:84K Time:0MS
Language:C++ Result:Output Limit Exceed
Source
#include <stdio.h>
#include <math.h>
typedef unsigned long num;
int main()
{
while(1)
{
num a;
scanf("%lu",&a);
{
if(a==0)return 0;
num b,k=0;
num last=0;
num dk;
num mid=a+sqrt(a*a+1.0);
for(b=a+1;(k==0)|(b<mid);b++)
{
if((b*b+1)%(b-a)==0)
{
dk=(num)((b*b+1)/(b-a));
if((k==0)||(dk<k))k=dk;
}
}
printf("%lu\n",k);
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator