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 karlgeorge at 2017-02-01 09:48:25 on Problem 2429
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
long long gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int main(){
    long long g,l,j;
    scanf("%I64d%I64d",&g,&l);
    for(long long i=0;i<sqrt(g*l);i++){
        long long a=sqrt(g*l)-i;
        long long b=g*l/a;
        if(a*b!=l*g)continue;
        if(gcd(b,a)==g){
            printf("%I64d %I64d\n",a,b);
            break;
        }
    }
    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