您的位置:首页 > 其它

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

……

题解:

打表找数,注意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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: