Problem 34
Problem 34
https://projecteuler.net/problem=34
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
145是一个神奇的数字,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.
注意:不包括1和2。
def factorial(num):
f = 1
for i in range(1, num+1):
f *= i
return f tot = 0
nums = []
for i in range(3, 99999):
print(i)
digits = list(str(i))
if i < factorial(int(max(digits))):
continue
multi = 0
for digit in digits:
multi += factorial(int(digit))
if multi == i:
nums.append(i)
tot += i print(nums)
print(tot)
Problem 34的更多相关文章
- (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: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 ...
- 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 number ...
- ●UOJ 34 多项式乘法
题链: http://uoj.ac/problem/34 题解: FFT入门题. (终于接触到迷一样的FFT了) 初学者在对复数和单位根有简单了解的基础上,可以直接看<再探快速傅里叶变换> ...
- 【UOJ #34】多项式乘法
http://uoj.ac/problem/34 看了好长时间的FFT和NTT啊qwq在原根那块磨蹭了好久_(:з」∠)_ 首先设答案多项式的长度拓展到2的幂次后为n,我们只要求出一个g(不是原根)满 ...
- 拆系数FFT
学习内容:国家集训队2016论文 - 再谈快速傅里叶变换 模板题:http://uoj.ac/problem/34 1.基本介绍 对长度为L的\(A(x),B(x)\)进行DFT,可以利用 \[ \b ...
- 【uoj34】 多项式乘法
http://uoj.ac/problem/34 (题目链接) 题意 求两个多项式的乘积 Solution 挂个FFT板子. 细节 FFT因为要满足$n$是$2$的幂,所以注意数组大小. 代码 // ...
- UOJ34 多项式乘法(非递归版)
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...
- 论文阅读 | A Survey on Multi-Task Learning
摘要 多任务学习(Multi-Task Learning, MTL)是机器学习中的一种学习范式,其目的是利用包含在多个相关任务中的有用信息来帮助提高所有任务的泛化性能. 首先,我们将不同的MTL算法分 ...
随机推荐
- 谈谈c++纯虚函数的意义!
纯虚函数的存在有什么意义呢?相信大学假设有c++这么课程.在讲到纯虚函数时,必然会讲到纯虚函数是面向接口编程的基础. 如今和大家分享下纯虚函数设计的原由.目的.产生的效果. 现代软件project很庞 ...
- coffeescript的上下文
CoffeeScript代码中,变量,甚至函数前面有时会带上一个@符号,那么翻译到 javascript里,就是 "this." 这就涉及到运行过程中的上下文. 这个this指什么 ...
- oc68--NSString
// // main.m // 字符串截取 #import <Foundation/Foundation.h> int main(int argc, const char * argv[] ...
- SQL分离附加数据库
转自:http://www.jb51.net/article/36624.htm
- 62. ExtJS + fileuploadfield实现文件上传
转自:https://www.cnblogs.com/yzuzhang/p/5128174.html 后台服务端接收文件的代码: /** * 后台上传文件处理Action */ @RequestMap ...
- PCB C# MongoDB 查询(SQL,NOSQL,C#对比)
一.准备阶段 1.查询数据清单准备 2.这里先将SQL语句执行顺序列出来,方便后面语句对比更好理解 ()SELECT ()DISTINCT ()<Top Num> <select l ...
- js 二叉搜索树
二叉搜索树:顾名思义,树上每个节点最多只有二根分叉:而且左分叉节点的值 < 右分叉节点的值 . 特点:插入节点.找最大/最小节点.节点值排序 非常方便 1 2 3 4 5 6 7 8 9 10 ...
- CSS元素超出部分滚动,并隐藏滚动条
方法一, 利用 css 3 的新特性 -webkit-scrollbar, 但是这种方式不兼容 火狐 和 IE <!DOCTYPE html> <html> <head ...
- 题解报告:hdu 1846 Brave Game(巴什博弈)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1846 Problem Description 十年前读大学的时候,中国每年都要从国外引进一些电影大片, ...
- Android内存管理(8)Dalvik,ART和 .dex 是什么*
什么是Dalvik: Dalvik是Google公司自己设计用于Android平台的Java虚拟机.Dalvik虚拟机是Google等厂商合作开发的Android移动设备平台的核心组成部分之一. Da ...