# 擅长排列的小明

## 擅长排列的小明

```2
3 1
4 2```

```1
2
3
12
13
14
21
23
24
31
32
34
41
42
43```

```#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;
int ans[10];
int vis[10];
struct work_arg{
int n, m;
work_arg(int n, int m){
this->n = n; this->m = m;
}
work_arg(){

}
};

void dfs(int i, int n, int m);

void *work(void* arg){
work_arg* warg = (work_arg *)arg;
int n = warg->n, m = warg->m;
memset(vis, 0, sizeof(vis));
dfs(0, n, m);
}

void dfs(int i, int n, int m){
if(i == m){
for(int p = 0; p < m; p++){
//if(p)printf(" ");
printf("%d", ans[p]);
}
puts(" ");
return;
}
for(int p = 1; p <= n; p++){
if(vis[p])continue;
vis[p] = 1;
ans[i] = p;
dfs(i + 1, n, m);
vis[p] = 0;
}
}

int main(){
int T;
scanf("%d", &T);
while(T--){
int m, n;
scanf("%d%d", &n, &m);
work_arg arg(n, m);
}
return 0;
}```

## NYOJ 469 擅长排列的小明（二）

#include<stdio.h>int main(){ int a[56]={0,1,1,2,4}; for(int i=5;i<56;i++) a[i]=a[i-1]+a[i-3]+1; int num; //scanf("%d\n",&num); while(~scanf("%d",&num)) { //int n; //scanf("%d",&n); printf("%d\n"