All tasks
Mediummathloops

Armstrong Number

Time limit 2 s · Memory 64 MBAcceptance: —Solved by: 0

Statement

You are given an integer n. Print YES if it is an Armstrong number, otherwise NO. A k-digit Armstrong number equals the sum of the k-th powers of its digits: for example, 153 = 1^3 + 5^3 + 3^3.

Examples

Example 1
Input
153
Output
YES
Example 2
Input
100
Output
NO

Constraints

  • 1 ≤ n ≤ 10^9
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.