提交时间:2023-10-05 11:14:40
运行 ID: 105168
#include<bits/stdc++.h> using namespace std; int num,a[10001],n,r; bool b[10001]; inline void dfs(int k) { for(int i=1;i<=n;++i) if(!b[i]) { a[k]=i, b[i]=1; if(k==r && a[1]==1) num+=1; else dfs(k+1); b[i]=0; } } signed main() { cin>>n>>r; dfs(1); cout<<num; return 0; }