DFS
来源:互联网 发布:电脑软件无法安装 编辑:程序博客网 时间:2024/05/29 12:23
DFS
Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6254 Accepted Submission(s): 3850
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......C 语言程序代码/*比较简单,理一下思路即可*/#include<stdio.h>int f[10]={1,1},a[10];void dfs(){ int i; for(i=2;i<10;i++) { f[i]=f[i-1]*i; }}int find(int n){ int sum=0,i,temp,m; m=n; while(n) { temp=n%10; sum+=f[temp]; n/=10; } if(m==sum) return 1; return 0;}int main(){ dfs(); int i; for(i=1;i<=47483;i++)//开太大虽也能算出结果,但超时,所以根据得出的结果将其范围缩小 if(find(i)) printf("%d\n",i); return 0;}
0 0
- DFS
- DFS
- dfs
- dfs
- dfs
- dfs
- DFS
- DFS
- dfs
- DFS
- DFS
- DFS
- dfs
- DFS
- dfs
- dfs
- dfs
- dfs
- Static修饰成员变量
- Arbitrage (Uva 104 dp+floyd)
- HAProxy+Keepalived实现Web服务器负载均衡
- 黑马程序员——Java 面向对象_多态
- 最小生成树问题的常规分析过程
- DFS
- DPDK 内存管理(二)(rte_mempool 内存管理)
- <h3>QT中使用QNetworkAccessManager类进行POST数据
- 安装部署 CoreOS + Kubernetes 1
- hdu 2845 Beans dp
- cocos2d-x学习之box2d物理引擎打砖块
- Fibonacci again and again(hdu1848+SG打表)
- 一图看尽Docker容器文件系统
- 用UISegmentControl写简易的汤姆猫