HDU 2212 DFS

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.