Project Euler Problem 12-Highly divisible triangular number
最直接的想法就是暴力搞搞,直接枚举,暴力分解因子。再好一点,就打个素数表来分解因子。假设num=p1^a1p2^a2...pn^an,则所有因子个数为(a1+1)(a2+1)...(an+1)。
再好一点呢,还是要利用积性函数。假设因子个数函数为f(x),因为num=n(n+1)/2,所以num2=n(n+1),因为n和n+1为相邻的正整数,所以互质,所以f(2num)=f(n)f(n+1),
则f(num)=f(n)f((n+1)/2)(n+1为偶数)或者f(num)=f(n/2)*f(n+1)(n为偶数)。
人懒,写了个暴力的,140ms
Project Euler Problem 12-Highly divisible triangular number的更多相关文章
- project euler 12 Highly divisible triangular number
Highly divisible triangular number Problem 12 The sequence of triangle numbers is generated by addin ...
- Highly divisible triangular number
我的那个暴力求解,太耗时间了. 用了网上产的什么因式分解,质因数之类的.确实快!还是数学基础不行,只能知道大约. The sequence of triangle numbers is generat ...
- projecteuler---->problem=12----Highly divisible triangular number
title: The sequence of triangle numbers is generated by adding the natural numbers. So the 7th trian ...
- Project Euler Problem 10
Summation of primes Problem 10 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of ...
- Project Euler problem 68
题意须要注意的一点就是, 序列是从外层最小的那个位置顺时针转一圈得来的.而且要求10在内圈 所以,这题暴力的话,假定最上面那个点一定是第一个点,算下和更新下即可. #include <iostr ...
- Project Euler Problem (1~10)
1.If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. Th ...
- Project Euler Problem 8-Largest product in a series
直接暴力 写完才想到,代码写矬了,扫一遍就出结果了,哪还用我写的这么麻烦 ss = '''73167176531330624919225119674426574742355349194934 9698 ...
- Project Euler problem 62
题目的大意很简单 做法的话. 我们就枚举1~10000的数的立方, 然后把这个立方中的有序重新排列,生成一个字符串s, 然后对于那些符合题目要求的肯定是生成同一个字符串的. 然后就可以用map来搞了 ...
- Project Euler problem 63
这题略水啊 首先观察一下. 10 ^ x次方肯定是x + 1位的 所以底数肯定小于10的 那么我们就枚举1~9为底数 然后枚举幂级数就行了,直至不满足题目中的条件即可break cnt = 0 for ...
随机推荐
- appium+python 启动一个app步骤
询问度娘搭好appium和python环境,开启移动app自动化的探索(基于Android),首先来记录下如何启动待测的app吧! 如何启动APP?1.获取包名:2.获取launcherActivit ...
- Spring Boot邮件功能
1.应用场景 邮件功能的应用场景可谓十分广泛,诸如注册用户.密码找回,消息通知.以及一些程序异常通知等都需要使用到该功能. 正是由于邮件功能的使用广泛,因此springboot也加在它的组件中添加了邮 ...
- python中星号
第一种情况:用在两表达式的中间,*表示乘法,**表示取幂,如: 1 2 3 4 >>> 2*5 10 >>> 2**7 128 第二种情况:用在变量的前面. 1,向 ...
- 安装tengine及淘宝会话保持模块
安装tengine及淘宝会话保持模块 下载http://tengine.taobao.org/ 解压tar -zxvf tengine-2.3.0.tar.gz 安装GCC: yum -y insta ...
- html 遮罩层以及弹出框的制作
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- LUOGU P1081 开车旅行 (noip 2012)
传送门 解题思路 这道题刚了一下午,主要就刚在set那里了.先写了一个暴力70分..之后优化预处理,看着大佬神犇们都用的什么双向链表之类的东西,本蒟蒻不会,又懒得手写平衡树,就拿了个set搞了搞,感觉 ...
- git操作github指令
常用git命令: $ git clone //本地如果无远程代码,先做这步,不然就忽略 $ cd //定位到你blog的目录下 $ git status //查看本地自己修改了多少文件 $ git ...
- IO流1 --- File类的实例化 --- 技术搬运工(尚硅谷)
构造器1 File(String pathname) //相对路径 File file1 = new File("hello.txt"); //windows绝对路径 File f ...
- 【水滴石穿】github_popular
项目不难,就是文件摆放位置跟别的不一样 https://github.com/chenji336/github_popular //定义入口是app.js ///** @format */ impor ...
- 去掉goland中间的令人烦躁的竖线
去掉“configured in code Style options”前面的勾即可.