시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 1677 1045 940 64.917%

문제

어떤 숫자 n이 자신을 제외한 약수들의 합으로 나타내어 지면, 그 수를 완벽한 수라고 한다. 

예를 들어 6은 6 = 1 + 2 + 3 으로 완벽한 수이다.

n이 완벽한 수 인지 아닌지 판단해주는 프로그램을 작성하라.

입력

입력은 테스트 케이스마다 한 줄 간격으로 n이 주어진다. (2 < n < 100, 000)

입력의 마지막엔 -1이 주어진다.

출력

테스트케이스 마다 한줄에 하나씩 출력해야 한다.

n이 완벽한 수라면, n을 n이 아닌 약수들의 합으로 나타내어 출력한다(예제 출력 참고).

이 때, 약수들은 오름차순으로 나열해야 한다.

n이 완벽한 수가 아니라면 n is NOT perfect. 를 출력한다.

예제 입력 1

6
12
28
-1

예제 출력 1

6 = 1 + 2 + 3
12 is NOT perfect.
28 = 1 + 2 + 4 + 7 + 14

힌트

W3sicHJvYmxlbV9pZCI6Ijk1MDYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM1N2RcdWMyMThcdWI0ZTRcdWM3NTggXHVkNTY5IiwiZGVzY3JpcHRpb24iOiI8cD5cdWM1YjRcdWI1YTQgXHVjMjJiXHVjNzkwIG5cdWM3NzQgXHVjNzkwXHVjMmUwXHVjNzQ0IFx1YzgxY1x1YzY3OFx1ZDU1YyBcdWM1N2RcdWMyMThcdWI0ZTRcdWM3NTggXHVkNTY5XHVjNzNjXHViODVjIFx1YjA5OFx1ZDBjMFx1YjBiNFx1YzViNCBcdWM5YzBcdWJhNzQsJm5ic3A7PHNwYW4gc3R5bGU9XCJsaW5lLWhlaWdodDoxLjZlbVwiPlx1YWRmOCBcdWMyMThcdWI5N2MgXHVjNjQ0XHViY2JkXHVkNTVjIFx1YzIxOFx1Yjc3Y1x1YWNlMCBcdWQ1NWNcdWIyZTQuJm5ic3A7PFwvc3Bhbj48XC9wPlxyXG5cclxuPHA+XHVjNjA4XHViOTdjIFx1YjRlNFx1Yz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