2 solutions

  • 0
    @ 2025-12-8 22:31:37

    A1753 组合型枚举

    和这题一样

    • 0
      @ 2025-12-8 22:30:34
      #include <bits/stdc++.h>
      using namespace std;
      int n,arr[30],m;
      bool b[30];
      void dfs(int x,int y)
      {
      	if(x==m+1)
      	{
      		for(int i=1;i<=m;i++)
      		{
      			cout<<arr[i]<<" ";
      		}
      		cout<<"\n";
      		return;
      	}
      	for(int j=y;j<=n;j++)
      	{
      		if(!b[j])
      		{
      			b[j]=true;
      			arr[x]=j;
      			dfs(x+1,j+1);
      			b[j]=false;
      		}
      	}
      	return;
      }
      int main()
      {
      	cin>>m>>n;
      	dfs(1,1);
      	return 0;
      }
      
      • 1

      Information

      ID
      2752
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      10
      Tags
      # Submissions
      5
      Accepted
      3
      Uploaded By