Problems > Armstrong Number

Armstrong Number

Difficulty: 1000 2000 ms 128 MB

math implementation

A K-digit number is an Armstrong number if the sum of its digits, each raised to the K-th power, equals the number itself (153 = 1³+5³+3³). Check N.

Input: one integer N.

Output: YES or NO.

Constraints:

  • 1 ≤ N ≤ 1018

Sample Tests

Input 1
153
Output 1
YES
Input 2
154
Output 2
NO

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.