include[HTML_REMOVED]
include[HTML_REMOVED]
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
const int N = 30;
int n, m;
int way[N];
void dfs(int u, int start)//u表示枚举到哪个位置,start从哪个数开始枚举
{
if(u > m )
{
for(int i = 1; i <= m; i ++ )
printf(“%d “, way[i]);
puts(“”);
return;
}
for (int i = start; i <= n; i ++ )
{
way[u] = i;
dfs(u + 1, i + 1);
way[u] = 0;
}
}
int main(){
scanf("%d%d", &n, &m);
dfs(1, 1);
return 0;
}
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla