1 条题解

  • 1
    @ 2025-12-21 14:39:20
    #include<bits/stdc++.h>
    using namespace std;
    int n,r;
    int a[21];
    void dfs(int x){
    	if(x==r+1){
    		for(int i=1;i<=r;i++){
    			cout<<setw(3)<<a[i]<<setw(3);
    		}
    		cout<<endl;
    	}
    	for(int i=x;i<=n;i++){
    		if(x>1&&i>a[x-1]||x==1){
    			a[x]=i;
    			dfs(x+1);
    		}
    	}
    }
    int main(){
    	cin>>n>>r;
    	dfs(1);
    	return 0;
    }
    
    • 1

    信息

    ID
    157
    时间
    1000ms
    内存
    125MiB
    难度
    3
    标签
    递交数
    3
    已通过
    3
    上传者