P17070 [GeeksforGeeks] Perfect number3759
普及-
题目描述

Given a number N. Check if it is perfect or not. A number is perfect if sum of factorial of its digit is equal to the given number.
Example 1:
Input: N = 23
Output: 0
Explanation: The sum of factorials of
digits of 23 is 2! + 3! = 2 + 6 = 8
which is not equal to 23. Thus, answer
is 0.
Example 2:
Input: N = 145
Output: 1
Explanation: The sum of factorials of digits
of 145 is 1! + 4! + 5! = 1 + 24 + 120 = 145
which is equal to 145.Thus, answer is 1.
Your Task:
You don't need to read input or print anything.Your task is to complete the function isPerfect() which takes a number N as input parameter and returns 1 if N is perfect.Otherwise, it returns 0.
Expected Time Complexity: O(Log_{10}N)
Expected Auxillary Space: O(constant)
Constraints:
1<=N<=10^{9}

输入格式

见题面

输出格式

见题面

样例输入
N = 23
样例输出
0