poj 3076 dancing links 解n*n的数独
hdu 3663 精确覆盖 dlx

字典序生成r组合

scturtle posted @ 2011年8月13日 17:05 in algorithm , 1933 阅读
# coding: utf-8

 ## n
#
 ## m

m=9
n=3
a=[i for i in range(n)]
ma=[m-n+i for i in range(n)] # 最大的一组

count=0

while 1:
    count+=1
    print a
    found=False
    for i in range(n)[::-1] : # 从后往前找可增的
        if a[i]<ma[i]:
            a[i]+=1
            for j in range(i+1,n): # 其后的按字典序初始化
                a[j]=a[j-1]+1
            found=True
            break
    if not found: break

print 'count:',count
pavzi.com 说:
2024年1月24日 14:33

Pavzi.com provides all the news about Gadgets, the Economy, Technology, Business, Finance and many more. The main concept or our aim behind this website has been the will to provide resources with full information on each topic which can be accessed through the Internet. To ensure that every reader gets what is important and worthy about the topic they search and link to hear from us. pavzi.com Our site is a multiple Niche or category website which will ensure to provide information and resources on each and every topic. Some of the evergreen topics you will see on our website are Career, Job Recruitment, Educational, Technology, Reviews and others. We are targeting mostly so it is true that Tech, Finance, and Product Reviews. The only reason we have started this website is to make this site the need for your daily search use.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter