hdu 2212 打表水题

xiaoxiao2021-02-28  108

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 ……

题解:

打表找数,注意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]; num/=10; } if(sum==i) cout<<i<<" "; } 1 2 145 40585*/ printf("1\n2\n145\n40585\n"); return 0; }
转载请注明原文地址: https://www.6miu.com/read-63223.html

最新回复(0)