| ||||||||||
| 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<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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator