hdu 2212 打表水题
2017-09-01 09:25
351 查看
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
……
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
……
题解:
打表找数,注意0的阶乘是0代码:
#include <iostream> #include <cstdio> using namespace std; const int maxn = 2147483647; int a[10]={1,1,2,6,24,120,720,5040,40320,362880}; typedef long long LL; int main() { /*for(LL i=1;i<=maxn;i++) { LL num=i,sum=0; while(num) { sum+=a[num%10]; num/=10; } if(sum==i) cout<<i<<" "; } 1 2 145 40585*/ printf("1\n2\n145\n40585\n"); return 0; }
相关文章推荐
- HDU 2212 DFS 水题
- HDU--2212 DFS【水题】
- hdu 2161 Primes(数学:素数打表+水题)
- HDU 2212 - DFS (暴力打表)
- Function Run Fun(hdu1579,打表水题)
- HDU 2088 核反应堆【打表 水题】
- hdu 2521 (数学:打表水题)
- HDU - 1061 Rightmost Digit 打表水题
- hdu 1056 HangOver (打表水题)
- HDU 2089 不要62 --- 水题+打表
- HDU:1215 七夕节(水题+打表)
- HDU 2212 DFS(打表)
- hdu 5104 素数打表水题
- HDU 2212 DFS(水题)
- HDU 2010 水仙花数(打表+水题)
- hdu 5104 素数打表水题
- HDU 1331--Function Run Fun【水题】【打表】
- UVALive2953 POJ1775 ZOJ2358 Sum of Factorials【打表+暴力+水题】
- HDU 1039 字符串判断(水题)
- 2016 ACM/ICPC Asia Regional Shenyang Online HDU 5900 QSC and Master(区间dp水题)