首页 > 学院 > 开发设计 > 正文

UVa-11388 GCD LCM

2019-11-08 01:42:20
字体:
来源:转载
供稿:网友

一开始想复杂了,若a,b都是G的倍数,则L也是G的倍数,所以如果L%G!=0,那么一定不存在,且发现a=G,b=L

#include<iostream>#include<cstring>#include<algorithm>using namespace std;int main(){	int T;	long long G,L;	cin>>T;	while(T--){		cin>>G>>L;		if(L%G!=0) cout<<"-1"<<endl;		else cout<<G<<" "<<L<<endl;			}	return 0;} 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表