亲和数

#include <cstdio>

int amicable(int n)
{
	int sum = 0;
	for(int i = 1; i < n; ++ i)
		if(n % i == 0)	sum += i;
		
	return sum;
}

int main()
{
	int n, a, b, p, q;
	scanf("%d", &n);
	while(n --)
	{
		scanf("%d %d", &a, &b);
		
		p = amicable(a);
		q = amicable(b);
		if(p == b && q == a)	printf("YES\n");
		else	printf("NO\n");
	}
	
	return 0;
}

  

posted @ 2019-08-01 17:04  青衫客36  阅读(286)  评论(0编辑  收藏  举报