DFS

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

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
......
 
所说最后觉得挺水的,但一来看见 [1, 2147483647] 就在想什么比较好的方法可以处理,结果想了半天也没想出来。一看题解,9!=3628801,也就是说10个9也就是36288010,1e7的复杂度,加上中间对每个位的处理,也就是不到1e8的复杂度,而题目给了2000ms,所以可以解决。
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int mul[]; void calcu()
{
mul[]=;
for(int i=;i<=;i++)
mul[i]=mul[i-]*i;
} bool cmp(int x)
{
int a,tem=;
a=x;
do
{
int mm=a%;
tem+=mul[mm];
a/=;
}while(a>);
if(x==tem)
return ;
else
return ;
} int main()
{
long long num1=,num2=;
calcu();
//cout<<mul[9];
for(int i=;i<=mul[]*;i++)
{
if(cmp(i))
printf("%d\n",i);
}
return ;
}

HDU_2212_水的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. Openjudge 1.13-21:最大质因子序列(每日两水)

    总时间限制:  1000ms 内存限制:  65536kB 描述 任意输入两个正整数m, n (1 < m < n <= 5000),依次输出m到n之间每个数的最大质因子(包括m和n ...

  3. [LeetCode] Container With Most Water 装最多水的容器

    Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). ...

  4. 如何装最多的水? — leetcode 11. Container With Most Water

    炎炎夏日,还是呆在空调房里切切题吧. Container With Most Water,题意其实有点噱头,简化下就是,给一个数组,恩,就叫 height 吧,从中任选两项 i 和 j(i <= ...

  5. Codeforces 刷水记录

    Codeforces-566F 题目大意:给出一个有序数列a,这个数列中每两个数,如果满足一个数能整除另一个数,则这两个数中间是有一条边的,现在有这样的图,求最大联通子图. 题解:并不需要把图搞出来, ...

  6. Bzoj3041 水叮当的舞步

    Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 132  Solved: 75 Description 水叮当得到了一块五颜六色的格子形地毯作为生日礼物 ...

  7. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  8. bzoj2002弹(dan)飞绵羊 分块水过

    据说是道lct求深度的题 但是在小猫大的指点下用分块就n^1.5水过了 = =数据忘记加强系列 代码极其不美观,原因是一开始是听小猫大讲的题意,还以为是弹到最前面... #include <cs ...

  9. bzoj1103树状数组水题

    (卧槽,居然规定了修改的两点直接相连,亏我想半天) 非常水的题,用dfs序(而且不用重复,应该是直接规模为n的dfs序)+树状数组可以轻松水 收获:树状数组一遍A(没啥好骄傲的,那么简单的东西) #i ...

随机推荐

  1. linux内核研究-8-块设备I/O层

    http://blog.csdn.net/rill_zhen/article/category/1123087

  2. Angularjs中添加ckEditor插件

    使用方法看注释.主要解决帮上ngModel的问题 angular.module('newApp') .directive('ckeEditor', function() { return { /* F ...

  3. C++学习之函数模板与类模板

    泛型编程(Generic Programming)是一种编程范式,通过将类型参数化来实现在同一份代码上操作多种数据类型,泛型是一般化并可重复使用的意思.泛型编程最初诞生于C++中,目的是为了实现C++ ...

  4. C++学习之继承中的访问控制

    我们通常认为一个类有两种不同的用户:普通用户 和 类的实现者.其中,普通用户编写的代码使用类的对象,这部分代码只能访问类的公有(接口)成员:实现者则负责编写类的成员和友元的代码,成员和友元既能访问类的 ...

  5. Ndk开发笔记

    <pre name="code" class="cpp">ndk开发: 1.编译android本地程序的二种方法.q 2.安装ndk编译工具. 3. ...

  6. 设计模式之五:工厂方法模式(Factory Method)

    工厂方法模式:定义了一个创建对象的接口,由子类来决定详细实例化那个对象.工厂方法模式让类的实例化转移到子类中来推断. Define an interface for creating an objec ...

  7. tomcat的localhost_access_log日志文件

    一.服务器打印日志要关闭hibernate的日志,首先要把hibernate.show_sql设置为false;然后设置log4j.properties. # Control logging for ...

  8. bootstrap table load数据

    直接load数据: $("#button").click(function(){ var name=$("input[name='name']").val(); ...

  9. Mysql的简单使用(二)

    接上文Mysql的简单使用(一) 字段参数以“(字段名1 数据类型1,字段名2 数据类型2,......)”的形式构建. 关于mysql常用的数据类型,一下是比较常用的几种,想查阅比较详细的资料可以自 ...

  10. JavaScript检查是否包含某个字符

    转自:http://my.oschina.net/u/1450300/blog/389325 indexOf用法: indexOf 方法返回一个整数值,指出 String 对象内子字符串的开始位置.如 ...