Problem 2646 --Bitset II - Enumeration of Combinations

2646: Bitset II - Enumeration of Combinations

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $2$ 正确数量 $2$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 STL

Enumeration of Combinations

Print all combinations which can be made by kk different elements from 0,1,...,n10,1,...,n−1. Note that we represent 0,1,...n10,1,...n−1 as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation of a combination is calculated by bitwise OR of the selected elements.

Input

The input is given in the following format.

nknk

Output

Print the combinations ordered by their decimal integers. Print a combination in the following format.

dd: e0e0 e1e1 ...

Print ':' after the integer value dd, then print elements eiei in the combination in ascending order. Separate two adjacency elements by a space character.

5 3
7: 0 1 2
11: 0 1 3
13: 0 2 3
14: 1 2 3
19: 0 1 4
21: 0 2 4
22: 1 2 4
25: 0 3 4
26: 1 3 4
28: 2 3 4

Constraints

  • 1n181≤n≤18
  • knk≤n


推荐代码 查看2646 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$3 $ms] AOJ大管家 437047 2019-06-07 13:27:48
内存最少[$2020 $KB] 计爱玲 362674 2019-01-30 16:26:30
第一AC 计爱玲 362674 2019-01-30 16:26:30
第一挑战 计爱玲 362674 2019-01-30 16:26:30

赛题来源/所属竞赛 会津大学《C++ Programming II》 C++程序设计(高级)

竞赛编号 竞赛名称 竞赛时间 访问比赛