Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
欢迎参加IJCAI 2020麻将智能体竞赛,大奖等你拿!Welcome to IJCAI 2020 Mahjong AI competition with amazing prizes! | 北京大学《ACM/ICPC大学生程序设计竞赛训练》暑期课面向全球招生!

orz

Posted by Pzjay at 2010-04-30 17:07:12 on Problem 2245
In Reply To:只是一个生成组合的算法 Posted by:z1161y at 2009-05-26 20:56:07
> 首先初始化,将数组前n个元素置1,表示第一个组合为前n个数。 
> 然后从左到右扫描数组元素值的“10”组合,找到第一个“10”组合后将其变为 
> “01”组合,同时将其左边的所有“1”全部移动到数组的最左端。 
> 当第一个“1”移动到数组的m-n的位置,即n个“1”全部移动到最右端时,就得 
> 到了最后一个组合。 
> 例如求5中选3的组合: 
> 1 1 1 0 0 //1,2,3 
> 1 1 0 1 0 //1,2,4 
> 1 0 1 1 0 //1,3,4 
> 0 1 1 1 0 //2,3,4 
> 1 1 0 0 1 //1,2,5 
> 1 0 1 0 1 //1,3,5 
> 0 1 1 0 1 //2,3,5 
> 1 0 0 1 1 //1,4,5 
> 0 1 0 1 1 //2,4,5 
> 0 0 1 1 1 //3,4,5   

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator