- 亲和数
- 2013-09-13 22:03:26 @
#include <iostream>
#include <cmath>
using namespace std;
int factor(int a)
{
int sum=1;
for (int i=2;i<sqrt(a);i++)
{
if (a%i==0)
sum+=i+a/i;
}
return sum;
}
int main()
{
int a,b,count=0;
cin>>a>>b;
for (int j=a;j<=b;j++)
{
for (int k=a;k<=b;k++)
{
if (j==factor(k)&&k==factor(j))
count++;
}
}
cout<<count<<endl;
return 0;
}
0 条评论
目前还没有评论...