DFS 2212
来源:互联网 发布:如何创建淘宝店铺 编辑:程序博客网 时间:2024/05/28 16:04
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.
Input
no input
Output
Output all the DFS number in increasing order.
Sample Output
1
2
......
#include <cstdio>const int MAX = 50000;int factorial(int x);int main(int argc, const char* argv[]){ for (int i=1; i<=MAX; ++i) { int nTemp = i; int nSum = 0; while (nTemp != 0) { nSum +=factorial(nTemp%10); nTemp /= 10; } if (i == nSum) { printf("%d\n", i); } } return 0;}int factorial(int x){ int n = 1; for (int i=1; i<=x; ++i) { n *= i; } return n;}
0 0
- DFS 2212
- HDU 2212 DFS (伪·DFS)
- HDOJ 2212 DFS
- hdu 2212 DFS
- hdu 2212 DFS
- hdu 2212 DFS
- HDU 2212 DFS
- hdu-2212-DFS
- HDU 2212 DFS
- hdu 2212 DFS *
- hd 2212 DFS
- hdu DFS 2212
- hdoj 2212 DFS 【水】
- HDU 2212 DFS
- HDU--2212 DFS【水题】
- hdu 2212: DFS
- hdu-2212 DFS
- hdu 2212 DFS
- mysql学习
- hdu 1114 Piggy-Bank (完全背包+背包放满)
- NYOJ268国旗问题
- Easyui防止跑出边框修正版,不跑出顶部版
- 常用数据结构(十种)
- DFS 2212
- 今晚乒乓球赛输给老罗, 太轻敌了, 大意失荆州!
- YUV转为IplImage格式(I420和YV12)
- poj 1681 Painter's Problem(高斯消元)
- 【程序17】Python 字符串
- 嵌入式系统测试方案探讨
- Reporting Service Time Out(原)
- Android 再按一次返回键退出程序实现思路
- 【程序18】序列遍历计算