UVa 11388 & 丝帛

时间:2023-12-04 16:39:26

一直在想丝帛题要不要贴呢...后来觉得还是贴了吧...反正没人看...blog是开给自己看的...偶尔无聊打打blog也显得生活非常充实...

 题意:

  给一个gcd和lcm求满足啊他们的最小的a和b.

 SOL:

  还想着质因数分解来着...转念一想比gcd小的数的gcd也不能变成G啊...这不是丝帛么...那最小的不就是gcd么...

  数论用几个丝帛题开头好了 = =...

  

  Code:

    #include <cstdio>
#include <cstdlib>
#include <cstring> int main()
{
int n,G,L;
while ( scanf("%d",&n) != EOF )
for ( int t = 1 ; t <= n ; ++ t ) {
scanf("%d%d",&G,&L);
if ( L%G == 0 )
printf("%d %d\n",G,L);
else printf("-1\n");
}
return 0;
}