zoukankan      html  css  js  c++  java
  • Euler Project question 31 in python way

    # This python file uses the following encoding: utf-8
    # In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation:

    # 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).
    # It is possible to make £2 in the following way:

    # 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p
    # How many different ways can £2 be made using any number of coins?
    import time
    start = time.time()
    print "%s ways was found in %s seconds" % (4 + 2*len([(i, j, k, l, m) for i in range(0, 51) for j in range(0, 26) for k in range(0, 11) for l in range(0, 6) for m in range(0, 3) if i*1 + j*2 + k*5 + l*10 + m*20 == 50]) + 2*len([(i, j, k, l, m) for i in range(0, 101) for j in range(0, 51) for k in range(0, 21) for l in range(0, 11) for m in range(0, 6) if i*1 + j*2 + k*5 + l*10 + m*20 == 100]) + len([(i, j, k, l, m) for i in range(0, 151) for j in range(0, 76) for k in range(0, 31) for l in range(0, 16) for m in range(0, 8) if i*1 + j*2 + k*5 + l*10 + m*20 == 150]) + len([(i, j, k, l, m) for i in range(0, 201) for j in range(0, 101) for k in range(0, 41) for l in range(0, 21) for m in range(0, 11) if i*1 + j*2 + k*5 + l*10 + m*20 == 200]), time.time() - start)


    just too long, nees some improvement 

  • 相关阅读:
    clone()与clone(true)的区别
    内部插入节点的方法
    jquery动态创建页面元素
    removeClass() 方法
    addClass() 和 toggleClass()
    CSS()方法设置元素样式
    val()方法
    html() 和 text() 方法的区别
    C#导出Excel那些事
    Winform控件重写
  • 原文地址:https://www.cnblogs.com/cyberpaz/p/4034423.html
Copyright © 2011-2022 走看看