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

我以为是求连续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. Flask+Mysql搭建网站之安装Mysql

    安装Mysql # sudo apt-get install mysql-server 安装过程需要输入root密码,这个密码是mysql 的root密码,之后连接mysql会用到,这个要记住. 安装 ...

  2. js中widow.open()方法详解

    一. window.open() 支持环境: JavaScript1.0+/JScript1.0+/Nav2+/IE3+/Opera3+ 二.基本语法: window.open(pageURL,nam ...

  3. 推荐一款不错的dialog小工具:artDialog

    推荐一款不错的dialog小工具, 地址:http://www.planeart.cn/demo/artDialog/_doc/labs.html 相关介绍例如以下: artDialog是一个基于ja ...

  4. JDK动态代理实现原理--转载

    之前虽然会用JDK的动态代理,但是有些问题却一直没有搞明白.比如说:InvocationHandler的invoke方法是由谁来调用的,代理对象是怎么生成的,直到前几个星期才把这些问题全部搞明白了.  ...

  5. [转] GDB 下 watch的使用

    这里大概说下gdb调试程序时,watch的使用.至于原理尚不清楚,以后再做补充,还请见谅. watch通常需要和break,run,continue联合使用. 下面举例说明: 代码如下: #inclu ...

  6. ajax的来龙去脉

    这是我在博客园写的第一遍博客,之前都是只看不写,在园子里学到了不少的东西,现在也想着把自己的一些感悟写出来给大家分享一下. ajax技术可以说是Web2.0应用程序的技术基础,尽管软件经销商和开源社区 ...

  7. 关于ImageView加载出现OOM问题

    略感蛋疼,一直以为应该不是这个问题的,所以调试了一下午,后来测试了下如果在XML里面改变ImageView的src话会出现什么问题 结果如我预料,仍然是只能显示部分图片,因为之前有运行成功了,我也不清 ...

  8. <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>

    <bean id="validator" class="org.springframework.validation.beanvalidation.LocalVal ...

  9. 在SPItemEventReceiver中使用BeforeProperties和AfterProperties

    当你利用这些事件时,就很快会发现存在前(同步)后(异步)两种事件.其方法的后缀分别为“ing”(比如,ItemAdding)和“ed”(比如,ItemAdded),分别代表了变更发生前调用和发生后调用 ...

  10. ViewPager Indicator的使用方法

    原文:http://my.oschina.net/u/1403288/blog/208402 项目源码:https://github.com/wangjing0311/ViewPagerIndicat ...