A classic-car appraiser has a quick sanity check for odometer readings: take every digit of the reading, raise each one to the power equal to the total number of digits in the reading, and add them all up. If that sum reproduces the reading exactly, the appraiser calls the reading "digit-power stable" -- a nice invariant to spot-check before trusting an odometer's display. Given a reading, determine whether it is digit-power stable.
A single integer n on one line -- the odometer reading.
Print YES if n is digit-power stable, otherwise print NO.
Example 1
Input
153
Expected
YES
Explanation
153 has 3 digits. 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153, which equals the reading itself, so it is digit-power stable: YES.
Example 2
Input
10
Expected
NO
Explanation
10 has 2 digits. 1^2 + 0^2 = 1, which does not equal 10, so it is not digit-power stable: NO.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →