| ||||||||||
| 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 | |||||||||
求解释!!!。。。老是WA 无语了#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
__int64 gcd(__int64 a,__int64 b)
{
__int64 temp;
if(a<b)
{
temp=b;b=a;a=temp;
}
if(a%b==0)
return b;
else
return gcd(a-b,b);
}
int main()
{
__int64 a,b,x,y;
while(scanf("%I64d",&a)!=EOF)
{
scanf("%I64d",&b);
x=(__int64)sqrt(b/a);
int i=0;
while(y>0)
{
y=(b/a)/(x+i);
if((x+i)*y==b/a && gcd(x+i,y)==1)
{
if(y*a<(x+i)*a)
printf("%I64d %I64d\n",y*a,(x+i)*a);
else
printf("%I64d %I64d\n",(x+i)*a,y*a);
break;
}
i++;
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator