标签:style class blog c code tar
题意:给定两个数G,T,求a,b使gcd(a,b)=G,lcm(a,b)=T;
解题思路:1.T%G==0,否则无解。
2.输出a=gcd(a,b)=G,b=lcm(a,b)=T;
1 //Accepted 0 KB 16 ms 2 #include <cstdio> 3 #include <cstring> 4 int a,b; 5 void slove() 6 { 7 if (b%a!=0) 8 { 9 printf("-1\n"); 10 return ; 11 } 12 printf("%d %d\n",a,b); 13 } 14 int main() 15 { 16 int T; 17 scanf("%d",&T); 18 while (T--) 19 { 20 scanf("%d%d",&a,&b); 21 slove(); 22 } 23 return 0; 24 }
uva11388GCD LCM,布布扣,bubuko.com
标签:style class blog c code tar
原文地址:http://www.cnblogs.com/djingjing/p/3749353.html