/*2. 求400之内的一对亲密对数。所谓亲密对数就是指两个整数A和B(A不等于B),
且A的除本身外的所有因子(如,6的除本身外因子为1,2,3)之和等于另一个整数B,
B除本身外的所有因子之和等于A。则这两个数为亲密对数。*/
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int fun(int A) //求亲密对数
{
int B = 0;
for (int j = 1; j <= sqrt(A); j++)
{
if (!A % j)
{
B += j;
}
}
int Bs = 0;
for (int j = 0; j <= sqrt(B); j++)
{
if (!B % j)
{
Bs += j;
}
}
if (A == Bs)
{
return B;
}
else
return 0;
}
int main()
{
int A = 1;
for (int A = 1; A <= 400; A++)
{
int k = fun(A);
if (k&&k<=400)
{
cout << A << " " << k << endl;
}
}
return 0;
}