projecteuler---->problem=34----Digit factorials
Problem 34
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
puts (0..50000).select{|i|
i.to_s.length>1 && i == i.to_s.each_char.map{|d| (1..d.to_i).reduce(1,:*)}.reduce(:+)}.reduce(:+)
版权声明:本文博客原创文章,博客,未经同意,不得转载。
projecteuler---->problem=34----Digit factorials的更多相关文章
- Project Euler:Problem 34 Digit factorials
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are ...
- Project Euler 34 Digit factorials
题意:判断一个数 N 的各个位数阶乘之和是否为其本身,找出所有符合要求的数然后求和 思路:此题思路跟 30 题相同,找到枚举上界 10 ^ n <= 9! × n ,符合要求的 n < 6 ...
- Problem 34
Problem 34 https://projecteuler.net/problem=34 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 1 ...
- (Problem 34)Digit factorials
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are ...
- TJU Problem 2857 Digit Sorting
原题: 2857. Digit Sorting Time Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 3234 Accepted ...
- Project Euler:Problem 33 Digit cancelling fractions
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...
- Project Euler Problem 16-Power digit sum
直接python搞过.没啥好办法.看了下别人做的,多数也是大数乘法搞过. 如果用大数做的话,c++写的话,fft优化大数乘法,然后快速幂一下就好了.
- Problem 30
Problem 30 https://projecteuler.net/problem=30 Surprisingly there are only three numbers that can be ...
- Problem 63
Problem 63 https://projecteuler.net/problem=63 Powerful digit counts The 5-digit number, 16807=75, i ...
随机推荐
- wcf和webservice区别
1.WebService:严格来说是行业标准,不是技术,使用XML扩展标记语言来表示数据(这个是夸语言和平台的关键).微软的Web服务实现称为ASP.NET Web Service.它使用Soap简单 ...
- 9、Cocos2dx 3.0游戏开发找小三之工厂方法模式与对象传值
重开发人员的劳动成果,转载的时候请务必注明出处:http://blog.csdn.net/haomengzhu/article/details/27704153 工厂方法模式 工厂方法是程序设计中一个 ...
- 同一个PC只能运行一个应用实例(考虑多个用户会话情况)
原文:同一个PC只能运行一个应用实例(考虑多个用户会话情况) class Program { private static Mutex m; [STAThread] static void Main( ...
- opencv2使用形态学滤波对图像进行边缘及角点检測
#if !defined MORPHOF #define MORPHOF #include <opencv2/core/core.hpp> #include <opencv2/img ...
- redis源代码解读之内存管理————zmalloc文件
本文章主要记录本人在看redis源代码的一些理解和想法.由于功力有限,肯定会出现故障,所以.希望高手给出指正. 第一篇就是内存相关的介绍.由于我喜欢先看一些组件的东西,再看总体的流程. 先上一下代码吧 ...
- mysql5.6设置主从报错1236,Increase max_allowed_packet on master,原因却是Binlog偏移量不对
在试Mysql5.6,搭了个主从: CHANGE MASTER TO MASTER_HOST='1.2.3.4', master_user='slave', master_password='xxxq ...
- SQL Server高可用——日志传送(4-2)——部署
原文:SQL Server高可用--日志传送(4-2)--部署 前文再续,书接上一回.本章演示一下日志传送的具体过程 准备工作: 由于时间关系,已经装好了3台虚拟机,且同在一个域里面: SQL01:主 ...
- JDK自带的监控分析工具JConsole
非常多开发人员认为自己懂Java编程.事实是大多数开发人员都仅仅领会到了Java平台的皮毛.所学也仅仅够应付工作. 作者将深度挖掘Java平台的核心功能.揭示一些鲜为人知的事实.帮助您解决最棘手的编程 ...
- JAVA基础实例(三)--排序
冒泡排序 是一种简单的排序算法.它反复地走訪过要排序的数列,一次比較两个元素.假设他们的顺序错误就把他们交换过来.走訪数列的工作是反复地进行直到没有再须要交换,也就是说该数列已经排序完毕. 这个算法的 ...
- epoll演示样本
server参考是别人的代码 #include <stdio.h> #include <stdlib.h> #include <errno.h> #include ...