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

在HOJ上过了的,在这儿TLE

Posted by javawin at 2010-08-20 21:38:56 on Problem 2429

奇怪。。。。在HOJ上过了的,在这儿TLE。。。这么回事啊??
#include<cstdio>
#include<cmath>
int Gcd(long long a, long long  b)
{
 
     if(!a)
         return b;
 
 
     if(!b)
         return a;
     if(a>b)
	 {
        a ^= b;
        b ^=a;
        a ^= b;
     }
 
    long long  c;
 
     for(c = a % b ; c > 0  ; c = a % b)
	 {
         a = b;
         b = c;
     }
 
     return b;
 
}
 
int main()
{
	long long a,b,gcd,lcm;
	long long  temp;
	while(scanf("%lld%lld",&gcd,&lcm)!=EOF)
	{
		temp=lcm/gcd;
		for(a=sqrt(temp*1.0);a>=1;a--)
		{
			if(!(temp%a))
			{
				b=temp/a;
				if(Gcd(a,b)==1)
				break;
			}
		}
		printf("%lld %lld\n", (a > b ? b : a)*gcd, (a > b ? a : b)*gcd);
	}
	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