2 solutions

  • 1
    @ 2025-11-17 19:14:41
    #include<bits/stdc++.h>
    using namespace std;
    bool w(int n)
    {
    	int t=n,s=1;
    	for(int i=2;i<=sqrt(n);i++)
    	{
    		if(n%i==0)
    		{
    			s+=i;
    			if(n/i!=i)
    			{
    					s=s+n/i; 
    			}
    		}
    	}
    	if(t==s)return 1;
    	else return 0;
    }
    int main()
    {
    	int n;
    	cin>>n;
    	for(int i=2;i<=n;i++)
    	{
    		if(w(i))
    		{
    			cout<<i<<endl;
    		}
    		
    	}
        return 0;
    }
    
    • 1
      @ 2024-8-20 16:04:00
      #inlude<bits/stdc++.h>
      using namespace std;
      bool w(int n)
      {
      	int t=n,s=1;
      	for(int i=2;i<=sqrt(n);i++)
      	{
      		if(n%i==0)
      		{
      			s+=i;
      			if(n/i!=i)
      			{
      					s=s+n/i; 
      			}
      		}
      	}
      	if(t==s)return 1;
      	else return 0;
      }
      int main()
      {
      	int n;
      	cin>>n;
      	for(int i=2;i<=n;i++)
      	{
      		if(w(i))
      		{
      			cout<<i<<endl;
      		}
      		
      	}
      }
      
      ****
      
      
      • 1

      Information

      ID
      930
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      (None)
      # Submissions
      62
      Accepted
      23
      Uploaded By