UVa 11388 GCD LCM
花了點時間推導才發現原來是個送分題
因為GCD,LCM的GCD,LCM就是自己呀...
因為GCD,LCM的GCD,LCM就是自己呀...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* UVa 11388 | |
* Author: chchwy | |
* Last Modified: 2009.11.13 | |
*/ | |
#include<cstdio> | |
#include<cmath> | |
int main() | |
{ | |
int numCase; | |
scanf("%d", &numCase); | |
while (numCase--) | |
{ | |
int gcd, lcm; | |
scanf("%d %d", &gcd, &lcm); | |
if (lcm % gcd != 0) | |
puts("-1"); | |
else | |
printf("%d %d\n", gcd, lcm); | |
} | |
return 0; | |
} |
留言
張貼留言