Problem 75
Perfect Number
Easy · 10 pts · Math
Problem
A perfect number is a positive integer equal to the sum of its proper divisors: its positive divisors other than the number itself. For example, 6 is perfect because 1 + 2 + 3 = 6. The number 1 has no proper divisors, so it is not perfect. Given N, decide whether it is perfect. Divisors come in pairs d and N / d, so checking d up to the square root of N finds all of them quickly; be careful not to count the square root twice.
Input
A single integer N.
Output
Print YES or NO.
Constraints
1 <= N <= 100000000
Example input
28
Example output
YES
Explanation
The proper divisors of 28 are 1, 2, 4, 7 and 14. Their sum is 1 + 2 + 4 + 7 + 14 = 28, which equals the number, so the answer is YES.