hdu2212 DFS
来源:互联网 发布:svakom 知乎 编辑:程序博客网 时间:2024/06/06 05:38
Problem Description
A DFS(digital factorial sum) number is found by summing the factorial of every digit of a positive integer.
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 are shown below.
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 are shown below.
Input
no input
Output
Output all the DFS number in increasing order.
Sample Output
12......#include<stdio.h>int f[15],an;int pass(unsigned int sum)//判断每一位的介层和是不是等于本身,反回是几位数{ unsigned int su=0,a=sum; int k,t=0; while(a>0) { k=a%10; su+=f[k]; a/=10; t++; } return (su==sum)?t:0;}void DFS(unsigned int sum,int k,int t)//k是sum要达到多少位数,t是当前的数是几位数{ int e; if(pass(sum)==k)//只有当反回的位数等要求的位数才输出,不然会重复 printf("%d\n",sum); if(t<k)//当前的位数达不到要求的位数才继续加 for(e=0;e<10;e++) if((e!=0||t!=0)&&sum*10+e<=2147483647)//(e!=0||t!=0)是控制最高位不为0 { DFS(sum*10+e,k,t+1); }}int main(){ int i; f[0]=1; for(i=1;i<10;i++) f[i]=f[i-1]*i; for(i=1;i<6;i++) DFS(0,i,0);}
- HDU2212 DFS
- hdu2212 DFS
- HDU2212 DFS
- HDU2212-DFS
- HDU2212-DFS
- HDU2212 DFS 【水题】
- HDU2212 DFS【水题】【打表】
- HDu2212
- HDU2212
- Hdu2212 dfs (搜索&剪枝or打表)
- DFS
- DFS
- dfs
- dfs
- dfs
- dfs
- DFS
- DFS
- Mac下SVN软件
- 百度文库会员制度悄然上线
- POJ 1195 Mobile phones(二维树状数组)
- Map中add时自动类型转换的问题
- 随手记(C & C++)
- hdu2212 DFS
- html之简单网页制作一
- hdu题目分类
- POJ 1200 Crazy Search
- Mac下串口测试软件
- 18-数据结构_树-定义和分类
- 关于动态链接库哪些问题
- malloc(0)
- HDOJ1069 猴子和香蕉【DP】