CH0301 递归实现指数型枚举
Description
从
Input
一个整数 n。
Output
每行一种方案。同一行内的数必须升序排列,相邻两个数用恰好 1 个空格隔开。对于没有选任何数的方案,输出空行。本题有自定义校验器(SPJ),各行(不同方案)之间的顺序任意。
Sample Input
1 | 3 |
Sample Output
1 | 3 |
Limit
| Time Limit | Memory Limit |
|---|---|
| 1 秒(C/C++/Rust/Pascal),2 秒(其他语言) | 256 M(C/C++/Rust/Pascal),512 M(其他语言) |
Analysis
这道题没什么特别的,递归就好。不过在动手之前可以分析一下时间复杂度:
若是求规模为
把
而每个子集都会进入一次 DFS,共1048576,大概能在
Solve
1 |
|
Ref
- Title: CH0301 递归实现指数型枚举
- Author: Neurocoda
- Created at : 2026-09-28 21:53:41
- Updated at : 2026-09-28 22:19:41
- Link: https://neurocoda.com/p/915dfe3f.html
- License: This work is licensed under CC BY-ND 4.0.
Recommend