这个我开始理解错了,算错了。

我以为是求连续5个数的最大值,结果,是连接5个数相乘的最大值。

英语不好,容易吃亏啊。

Find the greatest product of five consecutive digits in the 1000-digit number。

73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450

代码:

str = "\
73167176531330624919225119674426574742355349194934\
96983520312774506326239578318016984801869478851843\
85861560789112949495459501737958331952853208805511\
12540698747158523863050715693290963295227443043557\
66896648950445244523161731856403098711121722383113\
62229893423380308135336276614282806444486645238749\
30358907296290491560440772390713810515859307960866\
70172427121883998797908792274921901699720888093776\
65727333001053367881220235421809751254540594752243\
52584907711670556013604839586446706324415722155397\
53697817977846174064955149290862569321978468622482\
83972241375657056057490261407972968652414535100474\
82166370484403199890008895243450658541227588666881\
16427171479924442928230863465674813919123162824586\
17866458359124566529476545682848912883142607690042\
24219022671055626321111109370544217506941658960408\
07198403850962455444362981230987879927244284909188\
84580156166097919133875499200524063689912560717606\
05886116467109405077541002256983155200055935729725\
71636269561882670428252483600823257530420752963450\
"
print str
max = 0
cur = 0
for i in xrange(1,len(str)-4):
    cur = int(str[i])*int(str[i+1])*int(str[i+2])*int(str[i+3])*int(str[i+4])
    if cur > max:
        max = cur
        print str[i],str[i+1],str[i+2],str[i+3],str[i+4]

print max

Largest product in a series的更多相关文章

  1. projecteuler Problem 8 Largest product in a series

    The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = ...

  2. 【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 × ...

  3. Problem 8: Largest product in a series

    先粘实现代码,以后需要再慢慢补充思路 s = ''' 73167176531330624919225119674426574742355349194934 9698352031277450632623 ...

  4. Project Euler 8 Largest product in a series

    题意:寻找这 1000 个数中相邻 13 个数相乘积最大的值 思路:首先想到的是暴力,但是还可以利用之前记录过的数值,什么意思呢?即在计算 2 - 14 后,再计算 3 - 15 时完全可以利用之前计 ...

  5. Largest product from 3 integers

    https://github.com/Premiumlab/Python-for-Algorithms--Data-Structures--and-Interviews/blob/master/Moc ...

  6. Largest product in a grid

    这个比前面的要复杂点,但找对了规律,还是可以的. 我逻辑思维不强,只好画图来数数列的下标了. 分四次计算,存入最大值. 左右一次,上下一次,左斜一次,右斜一次. In the 2020 grid be ...

  7. projecteuler---->problem=8----Largest product in a series

    title: The four adjacent digits in the 1000-digit number that have the greatest product are 9 9 8 9 ...

  8. R语言学习——欧拉计划(11)Largest product in a grid

    Problem 11 In the 20×20 grid below, four numbers along a diagonal line have been marked in red. 08 0 ...

  9. Project Euler 11 Largest product in a grid

    题意:在这个20×20方阵中,四个在同一方向(从下至上.从上至下.从右至左.从左至右或者对角线)上相邻的数的乘积最大是多少? 思路:暴力去枚举以 ( x , y ) 为中心拓展的四个方向 /***** ...

随机推荐

  1. HTTP学习笔记6-请求报头

    29,请求报头: 请求报头允许客户端向服务器端传递该请求的附加信息以及客户端自身的信息. 30,Accept: Accept请求报头域用于指定客户端接受哪类型的信息,例如:Accept: image/ ...

  2. SCOPE 中 SPFILE、MEMORY、BOTH 的小小区别

    ALTER SYSTEM 中 SCOPE=SPFILE/MEMORY/BOTH 的区别: SCOPE = SPFILE The change is applied in theserverparame ...

  3. qt之treeview例子

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.Qt import * from PyQt4. ...

  4. freemarker的使用心得

    freemarker眼下尽管使用的公司不多,可是在某些时候就必须使用,当须要遍历json数据的时候,眼下市面上的好多显示组件都达不到要求唯一能用的也就仅仅有freemarker了.在java里使用的模 ...

  5. udp协议基础(转自疯狂java讲义)

    第17章  网络编程 17.4  基于UDP协议的网络编程 UDP协议是一种不可靠的网络协议,它在通信实例的两端各建立一个Socket,但这两个Socket之间并没有虚拟链路,这两个Socket只是发 ...

  6. JavaBean-Servlet-JavaServerPage(转)

    1.servlet servlet是在服务器端执行的,具有良好的移植性,不论操作系统是Windows.Linux.Unix等等,都能将写好的Servlet程序放在这些操作系统上执行,是真正的写一次,到 ...

  7. AndroidSdk下载地址和环境变量配置

    一.Android Studio 下的AndroidSdk下载地址 http://tools.android-studio.org/index.php/sdk 二.Android Sdk环境变量设置 ...

  8. JS相关链接

    给开发者提供的 35 款 JavaScript 图形图表库: http://news.cnblogs.com/n/201518/ 主题:[前端必看]JavaScript推荐资料合集: http://w ...

  9. Lesson 6: Exploring the World of Typefaces

    Lesson 6: Exploring the World of Typefaces 这课提到的字体都是 英文 的. Article 1: More Google Web Fonts That Don ...

  10. MySQL -A不预读数据库信息(use dbname 更快)

    mysql数据库预读与不预读数据库信息(use dbname)—Reading table information for completion of table and column names   ...