AcWing 92. 递归实现指数型枚举—Java实现
原题链接
简单
作者:
___9
,
2021-05-20 09:20:18
,
所有人可见
,
阅读 322
import java.io.*;
public class Main {
static int N = 17, n;
static boolean[] st = new boolean[N];
static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException, InterruptedException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(in.readLine());
dfs(1);
out.flush();
}
private static void dfs(int u) throws IOException {
if (u > n) {
for (int i = 1; i <= n; i++)
if (st[i])
out.write(i + " ");
out.write("\n");
return;
}
st[u] = true;
dfs(u + 1);
st[u] = false;
dfs(u + 1);
}
}
兄弟有时间填个邀请码hhhhhhhhh(可以得AC币,邀请码在学生认证那填) 我的邀请码是:GUDFH