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 |
在HOJ上过了的,在这儿TLE奇怪。。。。在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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator