시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 2195 1333 1194 62.908%

문제

어떤 숫자 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
W3sicHJvYmxlbV9pZCI6Ijk1MDYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM1N2RcdWMyMThcdWI0ZTRcdWM3NTggXHVkNTY5IiwiZGVzY3JpcHRpb24iOiI8cD5cdWM1YjRcdWI1YTQgXHVjMjJiXHVjNzkwIG5cdWM3NzQgXHVjNzkwXHVjMmUwXHVjNzQ0IFx1YzgxY1x1YzY3OFx1ZDU1YyBcdWJhYThcdWI0ZTAgXHVjNTdkXHVjMjE4XHViNGU0XHVjNzU4IFx1ZDU2OVx1YWNmYyBcdWFjMTlcdWM3M2NcdWJhNzQsJm5ic3A7PHNwYW4gc3R5bGU9XCJsaW5lLWhlaWdodDoxLjZlbVwiPlx1YWRmOCBcdWMyMThcdWI5N2MgXHVjNjQ0XHVjODA0XHVjMjE4XHViNzdjXHVhY2UwIFx1ZDU1Y1x1YjJlNC4mbmJzcDs8XC9zcGFuPjxcL3A+XHJcblxyXG48cD5cdWM2MDhcdWI5N2MgXHViNGU0XHVjNWI0IDZcdWM3NDAmbmJzcDs2ID0gMSArIDIgKyAzIFx1YzczY1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LCB3aGVyZSAyICZsdDsgbiAmbHQ7IDEwMCwgMDAwIGZvciBlYWNoIGNhc2UuIEEgbGluZSBjb250YWluaW5nIC0xIGRlbm90ZXMgdGhlIGVuZCBvZiBpbnB1dCBhbmQgc2hvdWxkIG5vdCBiZSBwcm9jZXNzZWQuPFwvcD5cclxuIiwib3V0cHV0IjoiPHA+Rm9yIGVhY2ggY2FzZSwgZGV0ZXJtaW5lIHdoZXRoZXIgb3Igbm90IHRoZSBudW1iZXIgaXMgUGVyZmVjdC4gSWYgdGhlIG51bWJlciBpcyBQZXJmZWN0LCBkaXNwbGF5IHRoZSBzdW0gb2YgaXRzIHBvc2l0aXZlIGRpdmlzb3JzIGxlc3MgdGhhbiBpdHNlbGYuIFRoZSBvcmRlcmluZyBvZiB0aGUgdGVybXMgb2YgdGhlIHN1bSBtdXN0IGJlIGluIGFzY2VuZGluZyBvcmRlci4gSWYgYSBudW1iZXIgaXMgbm90IFBlcmZlY3QsIHByaW50ICZsZHF1bzsmbHQ7TlVNJmd0OyBpcyBOT1QgcGVyZmVjdC4mcmRxdW87IHdoZXJlICZsdDtOVU0mZ3Q7IGlzIHRoZSBudW1iZXIgaW4gcXVlc3Rpb24uIFRoZXJlIG11c3QgYmUgYSBzaW5nbGUgc3BhY2UgYmV0d2VlbiBhbnkgd29yZHMsIHN5bWJvbHMsIG9yIG51bWJlcnMgaW4gYWxsIG91dHB1dCwgd2l0aCB0aGUgZXhjZXB0aW9uIG9mIHRoZSBwZXJpb2QgYXQgdGhlIGVuZCBvZiB0aGUgc2VudGVuY2Ugd2hlbiBhIG51bWJlciBpcyBub3QgcGVyZmVjdC48XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

ACM-ICPC > Regionals > North America > Pacific Northwest Regional > 2013 Pacific Northwest Region Programming Contest F번