2 solutions

  • 0
    @ 2022-5-29 16:59:00
    #include <iostream>
    using namespace std;
    int perfectnum(int x)
    {
    	int sum=0;
    	for(int i=1;i<x;i++)
    	{
    		if(x%i==0){
    			sum+=i;
    		}
    	}
    	return sum;
    }
    int main()
    {
    	int m,n;
    	cin>>m>>n;
    	for(int i=m;i<=n;i++)
    	{
    		if(perfectnum(i)==i)
    		{
    			cout<<i<<' ';
    		}
    	}
    	return 0;
    }
    

    【入门】输出m和n范围内的完全数(完美数)

    Information

    ID
    476
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    8
    Tags
    # Submissions
    11
    Accepted
    7
    Uploaded By