View Code of Problem 93

    #include<iostream>
    using namespace std;
    int he(int x) {
        int sum = 0;
        for (int i = 1; i < x; i++) //为什么你们都知道因子不包括他自己??
        {
    	   if (x%i == 0) 
    	   {
    		  sum += i;
    	   }
        }
        return sum;
    }
     
    int main()
    {
        int a,b;
        cin >> a >> b;
        for (int i = a; i <= b; i++) 
        {
    	   int s = he(i);
    	   if (s <=b && he(s) == i&&s>i) {
    		  cout << i << " " << s << endl;
    	   }
        }
        return 0;
    }
     

Double click to view unformatted code.


Back to problem 93