Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
139872 | 刘星辰liuxingchen | 组合问题 | C++ | Accepted | 100 | 6 MS | 244 KB | 469 | 2024-03-26 15:15:49 |
#include<bits/stdc++.h> using namespace std; int n; int m; bool used[30]; vector<int> path; void dfs(int now,int Min) { if(now==m) { for(int i=0;i<path.size();i++) { cout<<path[i]; } cout<<endl; return ; } for(int i=Min;i<=n;i++) { if(used[i]==0) { used[i]=1; path.push_back(i); dfs(now+1,i+1); used[i]=0; path.pop_back(); } } return ; } int main() { cin>>n; cin>>m; dfs(0,1); return 0; }