当前位置:网站首页>93. Recursive implementation of combinatorial enumeration
93. Recursive implementation of combinatorial enumeration
2022-07-24 20:30:00 【To catty Hawthorn】
#include<iostream>
using namespace std;
int n,m;
//u Indicates the current number of digits that need to be enumerated ,k Indicates current needs Enumerate the number
void dfs(int u,int k,int state){
if(k == m){
for(int i = 0;i < n;i++)
if(state >> i & 1) cout << i + 1 << ' ';
cout << endl;
return;
}
if(u == n) return; // Enumeration to the last number still does not conform to enumeration m The condition of number , Is illegal
dfs(u + 1,k + 1,state | 1 << u);
dfs(u + 1,k,state); // Be careful , This statement should be below the previous one , You should enumerate and select this number first , Enumerate again and don't choose , Otherwise, the output order is wrong
}
int main()
{
cin >> n >> m;
dfs(0,0,0);
return 0;
}
边栏推荐
- Valdo2021 - vascular space segmentation in vascular disease detection challenge (I)
- [sciter]: window communication
- Flink Window&Time 原理
- What does software testing need to learn?
- Istio一之Envoy工作原理
- Modbus communication protocol specification (Chinese) sharing
- How to set appium script startup parameters
- How to integrate Kata in kubernetes cluster
- Synthesis route of ALA PNA alanine modified PNA peptide nucleic acid | AC ala PNA
- Bypass using the upper limit of the maximum number of regular backtracking
猜你喜欢
![[shader realizes the flicker effect of three primary colors of television signal _shader effect Chapter 5]](/img/ca/fa87bc199f3aefebddf6eb58784dc7.png)
[shader realizes the flicker effect of three primary colors of television signal _shader effect Chapter 5]

Synthesis of peptide nucleic acid PNA labeled with heptachydrin dye cy7 cy7-pna

Google's display of Chrome browser icons was abandoned, and it was intended to be a small rocket

Upgrade appium automation framework to the latest 2.0

How to use named slots

Native applets are introduced using vant webapp
![[training Day6] dream [priority queue] [greed]](/img/1b/309b53618b8a116862971799ce4e78.jpg)
[training Day6] dream [priority queue] [greed]

Azide labeled PNA peptide nucleic acid | methylene blue labeled PNA peptide nucleic acid | tyrosine modified PNA | Tyr PNA Qiyue Bio

Browser local storage webstroage

Each blogger needs to ask himself seven basic questions
随机推荐
clip:learning transferable visual models from natural language supervision
Unitywebgl project summary (unfinished)
[trial experience of Yuxin micro Wiota ad hoc network protocol development kit] RT thread BSP Software package production
Valdo2021 - vascular space segmentation in vascular disease detection challenge (2)
Easy to use office network optimization tool onedns
The difference between token and session, this classic interview question deserves a more in-depth answer
[training Day6] game [mathematics]
Delete remote and local branches
[learning notes] agc008
Failed to create a concurrent index, leaving an invalid index. How to find it
【LeetCode】1184. 公交站间的距离
Selenium uploads files in more ways than you think
Wechat stores build order pages and automatically grab tickets
Native applets are introduced using vant webapp
Software testing interview tips | if you don't receive the offer, I'll wash my hair upside down
2022 chemical automation control instrument test question simulation test platform operation
Understand the domestic open source Magnolia license series agreement in simple terms
C form application treeview control use
Working principle of envy of istio I
1. Mx6u-alpha development board (buzzer experiment)