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

求解释!!!。。。老是WA 无语了

Posted by AMCM at 2011-07-21 19:50:40 on Problem 2429
#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:
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