Dfs
Time limit:5000/2000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 5671 Accepted Submission (s): 3503
Problem Descriptiona DFS (digital factorial sum) number is found by summing the factorial of every digit of a positive inte Ger.
For example, consider the positive integer 145 = 1!+4!+5!, so it ' s a DFS number.
Now you should find out all the DFS numbers in the range of int ([1, 2147483647]).
There is no input for this problem. Output all the DFS numbers in increasing order. The first 2 lines of the output is shown below.
Inputno input
Outputoutput all the DFS number in increasing order.
Sample Output
12 ...
AUTHORZJT See this topic really scare me, think decisive to time out. Did not expect in fact, 4 numbers meet the conditions. The last code,
#include <stdio.h>int jieceng (int a) {int s,i;s=1;for (i=2;i<=a;i++) S*=i;return s;} int Weishu (int a) {int sum=0;int b;b=a;while (a) {Sum+=jieceng (a%10); a/=10;} if (sum==b) return 1;return 0; It's all pre-treatment. }int Main () {int n,i;for (i=1;i<=40585;i++) //Can be used first for (i=1;; i++) This enumeration to determine the number of all satisfies, and then control the interval length. Altogether there are four numbers 1,2,145,40585. {if (Weishu (i)) printf ("%d\n", I);}} in fact, a line of code can be AC. printf ("1\n2\n145\n40585\n");
HDU 2212 DFS