#C2234. Digit Factorial Sum

    ID: 45528 Type: Default 1000ms 256MiB

Digit Factorial Sum

Digit Factorial Sum

In this problem, you are given an integer ( n ). You need to determine if ( n ) is equal to the sum of the factorials of its digits. In other words, check whether [ n = \sum_{i=1}^{k} (d_i)! ] where ( d_i ) represents each digit of ( n ).

For example, 145 is a digit factorial sum because (1! + 4! + 5! = 145).

inputFormat

The input consists of a single integer ( n ) provided via standard input.

outputFormat

Output a single line with the string "YES" if ( n ) is equal to the sum of the factorials of its digits; otherwise, output "NO".## sample

145
YES