[codeforces 1285C] Fadi and LCM 最大公约数+约数

[codeforces 1285C] Fadi and LCM 最大公约数+约数

总目录详见https://blog.csdn.net/mrcrack/article/details/103564004

在线测评地址https://codeforces.com/contest/1285/problem/C

Problem Lang Verdict Time Memory
C - Fadi and LCM GNU C++11 Happy New Year! 31 ms 0 KB
#include <stdio.h>
#define LL long long
LL gcd(LL a,LL b){
	return b?gcd(b,a%b):a;
}
LL max(LL a,LL b){
	return a>b?a:b;
}
int main(){
	LL x;
	LL a,b,i,mn=(LL)9999999999999,c,d,e;
	scanf("%lld",&x);
	for(i=1;i*i<=x;i++)
		if(x%i==0){
			a=i,b=x/i;
			if(gcd(a,b)==1&&mn>max(a,b))
				mn=max(a,b),c=a,d=b;
		}
	printf("%lld %lld\n",c,d);
	return 0;
}
发布了475 篇原创文章 · 获赞 509 · 访问量 42万+

猜你喜欢

转载自blog.csdn.net/mrcrack/article/details/103939409