eolymp
bolt
Try our new interface for solving problems
Məsələlər

Federation Favorites

Federation Favorites

На пути к Ригель \textbf{7} главный инженер Джорди Лафордж и Дата обсуждали любимые номера. Джорди сообщил, что он предпочитает нарциссические числа: те, которые равны сумме цифр этого числа, где каждая цифра возведена в степень равную количеству цифр в этом числе. Дата согласился, что нарциссические числа интересны, но не настолько как его любимые: Совершенные числа. Джорди никогда не слышал о совершенных числах, поэтому Дата продолжал "Натуральное число называется Совершенным, если оно равно сумме своих положительных делителей, меньших его самого. Например \textbf{6} совершенно, так как \textbf{6} = \textbf{1 + 2 + 3}." Джорди начал думать над алгоритмом как определить совершенное число, но у него нет таких вычислительных ресурсов как у Даты. Помогите Джорди написать такую программу. \InputFile Input consists of a single entry per line. Each line contains a single positive integer \textbf{n}, where \textbf{2} < \textbf{n} < \textbf{100000} for each case. A line containing \textbf{-1} denotes the end of input and should not be processed. \OutputFile For each case, determine whether or not the number is Perfect. If the number is Perfect, display the sum of its positive divisors less than itself. The ordering of the terms of the sum must be in ascending order. If a number is not Perfect, print "\textbf{ is NOT perfect.}" where is the number in question. There must be a single space between any words, symbols, or numbers in all output, with the exception of the period at the end of the sentence when a number is not perfect.
Zaman məhdudiyyəti 5 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
6
12
28
-1
Çıxış verilənləri #1
6 = 1 + 2 + 3
12 is NOT perfect.
28 = 1 + 2 + 4 + 7 + 14
Mənbə 2013 North America - Pacific Northwest Region Programming Contest, Задача F