EularProject 48: 利用数组求和
2024-08-31 15:33:34
Problem 48
The series, 11+22+33+...+1010=10405071317.
Find the last ten digits of the series, 11+22+33+...+10001000.
Answer:
9110846700
Completed on Thu, 23 Jul 2015, 17:26
初步思路。能够利用元对的方式计算每个数须要乘的数
def func(a):
for i in range(0,len(a)):
a[i][1]*=a[i][0]
return a
a=[[i,i] for i in range(1000,0,-1)]
result=0
while len(a)>0:
result+=a.pop()[1]
a=func(a)
print(result%(pow(10,10)))
更进一步,能够利用数组下标得到须要乘的数
def func(a):
for i in range(0,len(a)):
a[i]=a[i]*(1000-i)
return a
a=[i for i in range(1000,0,-1)]
result=0
while len(a)>0:
result+=a.pop()
a=func(a)
print(result%(pow(10,10)))
最新文章
- ajax请求成功后新开窗口window.open()被拦截解决方法
- zeppelin-0.6.0安装配置
- 怎么在win7的64位旗舰版上配置coocs2d-x 3.2的android环境并且打包APK
- Java实现---堆排序 Heap Sort
- java代码实现如何获取当前经纬度?(安卓的话可以用GPS取)
- select2取值报错,Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('hidden') does not support selection.
- ajax traditional
- 图像处理工具包ImagXpress中如何定义图像显示属性
- java的nio之:java的nio系列教程之FileChannel
- 坑爹系列:sizeof运算符
- JS插件-日期
- hdoj 1200 To and Fro
- strace基本操作
- Mac下如何使用Vim
- Objective-c学习笔记3
- List之Union(),Intersect(),Except() 即并集,交集,差集运算。
- bzoj 4605: 崂山白花蛇草水
- eclipse中git解决冲突
- cocos2dx中的坐标系统
- Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-2.xml, reason:
热门文章
- legend---八、php对象如何转换成js对象
- 智课雅思短语---五、 in contrast / on the contrary
- 转一篇100offer的采访~35岁程序员是一种什么状态
- 6.CPU调度
- 深入理解JavaScript定时机制
- sql排名函数--四个
- Could not create connection to database server. Attempted reconnect 3 times. Giving up.错误
- Unity 框架(一)
- main()函数的形参
- javaEE之-------统计站点刷新量