Narcissistic numbers

In this exercice, we say that a natural number nn with kk digits is narcissistic, when nn is equal to the sum of the kk-th power of its digits. For example, 153 and 1634 are narcissistic numbers, as 153=13+53+33153 = 1^3+5^3+3^3 and 1634=14+64+34+541634 = 1^4 + 6^4 + 3^4 + 5^4.

A sequence of natural numbers is insufferably narcissistic when all the elements in the sequence are narcissistic numbers.

Write a program which, given a non-empty sequence of natural numbers, indicates whether it is insufferably narcissitic or not.

Your program must include, implement and use a function

    bool is_narcissistic (int n);

indicating whether a natural nn is narcissistic or not.

Input

The input is formed by a non-empty sequence of natural numbers.

Output

The program has to indicate whether the sequence is insufferably narcissitic.

Follow the format described in the examples. Your code should follow the style rules and include the appropriate comments.

Problem information

Author: Unknown
Translator: Maria Serna

Generation: 2026-01-25T10:37:15.929Z

© Jutge.org, 2006–2026.
https://jutge.org