145 is a strange number, because 1! + 4! + 5! = 1 + 24 + 120 = 145.
The sum of all numbers that indicate the factorial of each digit.
Note: Because 1! = 1 and 2! = 2 is not a sum, so they are not included.
---------------------------------------------------
The factorial of the original 0 is 1 .... I'm mentally retarded...
After a rough calculation, the data range cannot exceed 1000.
So, brute force ..
(In fact, there are only two numbers matching the rule ...)
#include<stdio.h>#include<algorithm>#include<iostream>#include<stdlib.h>#include<vector>#include<queue>#include<string.h>#include<math.h>using namespace std;int fat[10];void init(){ fat[0]=1; fat[1]=1; for(int i=2;i<=9;i++) { fat[i]=fat[i-1]*i; }}int cal(int x){ int ans=0; while(x) { ans=ans+fat[x%10]; x=x/10; } return ans;}int main(){ init(); int sum=0; for(int i=10;i<=100000000;i++) { if(i==cal(i)) { sum+=i; } } cout<<sum<<endl; return 0;}