39. Armstrong Number Check

Difficulty: easy · Math

Problem

A non-negative integer with `k` digits is an **Armstrong number** if the sum of each of its digits raised to the power `k` equals the number itself. For example `153` has 3 digits and `1^3 + 5^3 + 3^3 = 153`. Given `n`, print `Yes` if it is an Armstrong number and `No` otherwise.

Input

A single line containing the integer `n`.

Output

Print `Yes` or `No`.

Example 1

Input:
153
Output:
Yes

Explanation: 153 has 3 digits and 1 + 125 + 27 = 153.

Example 2

Input:
154
Output:
No

Explanation: 1 + 125 + 64 = 190, which is not 154.

Example 3

Input:
9474
Output:
Yes

Explanation: 9^4 + 4^4 + 7^4 + 4^4 = 6561 + 256 + 2401 + 256 = 9474.

Constraints

- 0 <= n <= 10^18

Solutions are judged against 3 sample and 12 hidden tests. Sign in to solve it · All problems