-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoj1528.cpp
More file actions
44 lines (37 loc) · 853 Bytes
/
poj1528.cpp
File metadata and controls
44 lines (37 loc) · 853 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
44
#include <cstdio>
#include <cmath>
int sumOfFactor(int n) {
if(n == 1) return 0;
int limit = sqrt(n);
int sum = 0;
// printf("%d\n", n);
for(int i = 1; i <= limit; ++i) {
if(n % i == 0) {
// printf("|%d\n", i);
sum += i;
int alt = n/i;
if(alt != n && alt > i)
sum += alt;
}
}
// printf("--- %d ---\n", sum);
return sum;
}
int main() {
int n;
printf("PERFECTION OUTPUT\n");
while(scanf("%d", &n) != EOF && n) {
int s = 0;
printf("%5d ", n);
int fn = sumOfFactor(n) ;
if(fn == n) {
printf("PERFECT\n");
} else if(fn > n) {
printf("ABUNDANT\n");
} else {
printf("DEFICIENT\n");
}
}
printf("END OF OUTPUT\n");
return 0;
}