hdu 2212 DFS

题意:把整数范围内的DFS列出。

注意:如果通过公式计算那么会超时。


java代码:

public class p2212 {
	static int temp = 0, sum = 0;
	static final int dfs[] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880 };

	public static void main(String[] args) {
		// 1位
		System.out.println(1);
		System.out.println(2);
		// 三位
		System.out.println(145);
		// 五位
		System.out.println(40585);
	}
}

测试代码:

public class p2212 {
	static int temp = 0, sum = 0;
	static final int dfs[] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880 };

	public static void main(String[] args) {
		// 1位
		System.out.println(1);
		System.out.println(2);
		// 三位
		System.out.println(145);
		// 五位
		System.out.println(40585);
	}

	private static void digital(int begin, int end) {
		for (int i = begin; i <= end; i++) {
			temp = i;
			// 取出该数的每一位
			// 求因子阶乘和
			sum = 0;
			while (temp > 0) {
				sum += dfs[temp % 10];
				temp /= 10;
			}
			// 查看是否满足条件
			if (sum == i) {
				System.out.println(i);
			}
		}
	}

}






DFS

Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6305    Accepted Submission(s): 3885


Problem Description
A DFS(digital factorial sum) number is found by summing the factorial of every digit of a positive integer.
通过把一个正整数的各个位的因子取出,求出它们阶乘的和,这时我们称他们为DFS(数字阶乘之和)数。
For example ,consider the positive integer 145 = 1!+4!+5!, so it's a DFS number.
举一个例子:正整数145=1!+4!+5!所以他是一个DFS数。
Now you should find out all the DFS numbers in the range of int( [1, 2147483647] ).
你可以天真的认为系统不会为难你,所有的数都在Int范围内。
There is no input for this problem. Output all the DFS numbers in increasing order. 
 这个没有输入。输出所有的DFS数,用递增数列。
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 ......
 

Author
zjt
 

Recommend
lcy   |   We have carefully selected several similar problems for you:   2203  2211  2265  2140  1195 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值