1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; int a[100],n,r; bool f[100]; void print(){ for(int i = 1;i <= r;i++){ cout<<a[i]<<" "; } cout<<endl; } void dfs(int k){ for(int i = 1;i <= n;i++){ if(f[i] == false && (k == 1 || i > a[k-1])){ f[i] = true; a[k] = i; if(k == r){ print(); }else{ dfs(k+1); } f[i] = false; } } } int main(){ cin>>n>>r; dfs(1); }
- 1
Information
- ID
- 10219
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By