You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
599 B
C++
26 lines
599 B
C++
#include <algorithm>
|
|
#include <cstdio>
|
|
#include <numeric>
|
|
using namespace std;
|
|
int a[100001], cnt;
|
|
int main()
|
|
{
|
|
int n;
|
|
while (scanf("%d", &n), ~n)
|
|
{
|
|
int cnt = 0;
|
|
for (int i = 1; (i << 1) <= n; i++)
|
|
if (n % i == 0)
|
|
a[cnt++] = i;
|
|
if (n != accumulate(a, a + cnt, 0))
|
|
printf("%d is NOT perfect.", n);
|
|
else
|
|
{
|
|
printf("%d", n);
|
|
for (int i = 0; i < cnt; i++)
|
|
printf(" %c %d", "=+"[i > 0], a[i]);
|
|
}
|
|
putchar('\n');
|
|
}
|
|
return 0;
|
|
} |