-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsol.cpp
More file actions
executable file
·43 lines (34 loc) · 731 Bytes
/
Copy pathsol.cpp
File metadata and controls
executable file
·43 lines (34 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <bits/stdc++.h>
using namespace std;
set<long long> properDivisors(long long n)
{
set<long long> factors = {1};
for (long long i = 2; i * i <= n; ++i)
{
if (n % i == 0)
{
factors.insert(i);
factors.insert(n / i);
}
}
return factors;
}
int main()
{
long long n;
while (cin >> n)
{
long long sum = 0;
for (long long f : properDivisors(n))
{
sum += f;
}
if (n == sum)
cout << n << " perfect" << endl;
else if (abs(n - sum) <= 2)
cout << n << " almost perfect" << endl;
else
cout << n << " not perfect" << endl;
}
return 0;
}