zoukankan      html  css  js  c++  java
  • python解无忧公主的数学时间编程题001.py

    python解无忧公主的数学时间编程题001.py

    """
    python解无忧公主的数学时间编程题001.py
    http://mp.weixin.qq.com/s?__biz=MzI5ODEwMDQyNw==&mid=402273249&idx=4&sn=aa2e79e154a13c5c94673d9a53e49c96&scene=24&srcid=0323mNu08KMNzbVyn7EbUN1d#rd
    2016年3月31日 05:16:39 codegay
    0-9组成的字典序第一百万个是多少?
    """
    from itertools import permutations
    
    #方法1 使用enumerate()当作计数器,只取第一百万个数字.
    result=[''.join([str(r) for r in v]) for k,v in enumerate(permutations(range(10)),1) if k==1000000]
    print(result)
    #['2783915460']
    #[Finished in 0.6s]
    
    #方法2 穷举后排序,取出一百万个数字.
    result=[''.join([str(r) for r in v]) for k,v in enumerate(permutations(range(10)),1)]
    result.sort()
    print(result[1000001])
    #2783915640
    #[Finished in 14.2s]
    
  • 相关阅读:
    动软代码生成器
    today
    命令执行漏洞
    Linux基础命令(二)
    动态主机配置协议DHCP
    Linux基础(一)
    ARP通信
    IP网段的判断
    配置yum源
    centos7-配置阿里yum源安装nginx
  • 原文地址:https://www.cnblogs.com/gayhub/p/5339762.html
Copyright © 2011-2022 走看看