145是个奇怪的数字。由于1!+ 4! + 5! = 1 + 24 + 120 = 145。

请求出能表示成其每位数的阶乘的和的全部数的和。

请注意:由于1! = 1和2! = 2不是和,故它们并不包含在内。

---------------------------------------------------

原来0的阶乘是1。。。。我弱智了。。。

粗略的运算一下数据范围。发现不会超过1000W。

于是,暴力吧。

(事实上结果仅仅有两个数符合规律。

。。)

#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<string.h>
#include<math.h>
using namespace std;
int fat[10];
void init()
{
fat[0]=1;
fat[1]=1;
for(int i=2;i<=9;i++)
{
fat[i]=fat[i-1]*i;
}
}
int cal(int x)
{
int ans=0;
while(x)
{
ans=ans+fat[x%10];
x=x/10;
}
return ans;
}
int main()
{
init();
int sum=0;
for(int i=10;i<=100000000;i++)
{
if(i==cal(i))
{
sum+=i;
}
}
cout<<sum<<endl;
return 0;
}

project euler-34的更多相关文章

  1. Project Euler 34 Digit factorials

    题意:判断一个数 N 的各个位数阶乘之和是否为其本身,找出所有符合要求的数然后求和 思路:此题思路跟 30 题相同,找到枚举上界 10 ^ n <= 9! × n ,符合要求的 n < 6 ...

  2. Python练习题 039:Project Euler 011:网格中4个数字的最大乘积

    本题来自 Project Euler 第11题:https://projecteuler.net/problem=11 # Project Euler: Problem 10: Largest pro ...

  3. Python练习题 035:Project Euler 007:第10001个素数

    本题来自 Project Euler 第7题:https://projecteuler.net/problem=7 # Project Euler: Problem 7: 10001st prime ...

  4. Python练习题 030:Project Euler 002:偶数斐波那契数之和

    本题来自 Project Euler 第2题:https://projecteuler.net/problem=2 # Each new term in the Fibonacci sequence ...

  5. [project euler] program 4

    上一次接触 project euler 还是2011年的事情,做了前三道题,后来被第四题卡住了,前面几题的代码也没有保留下来. 今天试着暴力破解了一下,代码如下: (我大概是第 172,719 个解出 ...

  6. Python练习题 029:Project Euler 001:3和5的倍数

    开始做 Project Euler 的练习题.网站上总共有565题,真是个大题库啊! # Project Euler, Problem 1: Multiples of 3 and 5 # If we ...

  7. Project Euler 9

    题意:三个正整数a + b + c = 1000,a*a + b*b = c*c.求a*b*c. 解法:可以暴力枚举,但是也有数学方法. 首先,a,b,c中肯定有至少一个为偶数,否则和不可能为以上两个 ...

  8. Project Euler 44: Find the smallest pair of pentagonal numbers whose sum and difference is pentagonal.

    In Problem 42 we dealt with triangular problems, in Problem 44 of Project Euler we deal with pentago ...

  9. project euler 169

    project euler 169 题目链接:https://projecteuler.net/problem=169 参考题解:http://tieba.baidu.com/p/2738022069 ...

  10. 【Project Euler 8】Largest product in a series

    题目要求是: The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × ...

随机推荐

  1. tf.reshape

    tf.reshape(tensor, shape, name=None) 其中,tensor是向量,或者说矩阵 shape是转换后的向量,或者转换后的矩阵形状 [2,1]转换成二行一列 [2,-1]转 ...

  2. 网络基础-IP地址

  3. solr的一些查询语法

    以下内容来自solr中国 1.1. 首先假设我的数据里fields有:name, tel, address 预设的搜寻是name这个字段, 如果要搜寻的数据刚好就是 name 这个字段,就不需要指定搜 ...

  4. alert(1) to win 7

    function escape(s) { // Pass inn "callback#userdata" var thing = s.split(/#/); if (!/^[a-z ...

  5. bzoj3991 [SDOI2015]寻宝游戏 树链的并

    题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=3991 题解 貌似这个东西叫做树链的并,以前貌似写过一个类似的用来动态维护虚树. 大概就是最终的 ...

  6. python高级:垃圾回收机制

    ---恢复内容开始--- 垃圾回收机制 1.计数引用机制 就是一个变量.数据结构.对象当没有人引用时,python的会启用垃圾回收机制,将其从内存中删除. 怎么看引用的次数呢?sys模块提供的sys. ...

  7. nginx主配置文件学习,以及nginx的反向代理和负载均衡

    1.nginx.conf主配置文件学习 worker_processes : 表示nginx的进程数,根据CPU的核数来定义,起到优化的作用.通过cat /proc/cpuinfo来查看核数 even ...

  8. macOS BLAS LAPACK

    /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers

  9. 【leetcode】1072. Flip Columns For Maximum Number of Equal Rows

    题目如下: Given a matrix consisting of 0s and 1s, we may choose any number of columns in the matrix and ...

  10. 【leetcode】778. Swim in Rising Water

    题目如下: 解题思路:本题题干中提到了一个非常重要的前提:"You can swim infinite distance in zero time",同时也给了一个干扰条件,那就是 ...