需注意AB的范围,最大是600000,所以需要用长整型表示
#include
#include
#include
#include
using namespace std;
int main()
{
int n;
long suma,sumb;
long a, b;
bool flag;
while (cin >> n)
{
while (n--)
{
suma = sumb = 0;
flag = false;
cin >> a >> b;
for (int i = 1; i <= a / 2; i++)
{
if (a%i == 0)
suma += i;
}
if (suma == b)
flag = true;
else flag = false;
for (int i = 1; i <= b / 2; i++)
{
if (b%i == 0)
sumb += i;
}
if (sumb == a)
flag = true;
else flag = false;
if (flag)
cout << "YES" << endl;
else cout << "NO" << endl;
}
}
}