原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=2040已AC
算法相对简单,这里直接贴出代码
#include <iostream>
using namespace std;
int f(int x)
{
int i;
int sum=0;
for(i=2;i<=x;i++){
if(x%i==0)
sum+=i;
}
return sum;
}
int main()
{
int M;
int a,b;
while(cin>>M){
for (int i = 0; i < M; ++i){
cin>>a>>b;
int s1=f(a);
int s2=f(b);
if(s1==s2)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}
return 0;
}