题目描述
简单题
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int perfect(int n)
{
int num = 0;
for (int i = 1; i < n; i++)
{
if (n % i == 0)
{
num += i;
}
}
if (num == n)
return 1;
return 0;
}
int main()
{
long long num;
cin >> num;
int N = 0;
for (int i = 1; i <= num; i++)
{
if (perfect(i))
N++;
}
cout << N << endl;
}