当前位置:网站首页>92. Recursive implementation of exponential enumeration
92. Recursive implementation of exponential enumeration
2022-07-24 20:30:00 【To catty Hawthorn】
#include<iostream>
using namespace std;
int n;
//u Indicates the current number of bits to enumerate ,state Represents the status of everyone , Use state compression ,32 position int Enough to compress all States
void dfs(int u,int state){
if(u == n){// Be careful , Is to n When you push the loop , No n-1, Because of n-1 Indicates current needs Enumerate the n position
for(int i = 0;i < n;i++)
if(state >> i & 1) cout << i + 1 << ' ';
cout << endl;
return; //return Don't forget .
}
dfs(u + 1,state);
dfs(u + 1,state | 1 << u);
}
int main(){
cin >> n;
dfs(0,0);
return 0;
}
边栏推荐
- [sciter]: window communication
- Software testing interview tips | if you don't receive the offer, I'll wash my hair upside down
- The difference between map and flatmap in stream
- Preview and save pictures using uni app
- [training Day10] tree [interval DP]
- [training Day8] interesting number [digital DP]
- Lunch break train & problem thinking: thinking about the problem of converting the string formed by hour: minute: second to second
- How does starknet change the L2 landscape?
- Upgrade appium automation framework to the latest 2.0
- Click the button to return to the top smoothly
猜你喜欢
![[training Day10] silly [simulation] [greed]](/img/31/94c32e05b498f8ad192f8ec2c500ca.png)
[training Day10] silly [simulation] [greed]

Student achievement management system based on PHP

Machine learning job interview summary: five key points that resume should pay attention to

Each blogger needs to ask himself seven basic questions

Near infrared dye cy7.5 labeling PNA polypeptide experimental steps cy7.5-pna|188re labeling anti gene peptide nucleic acid (agpna)

Fluoronisin peptide nucleic acid oligomer complex | regular active group alkyne, SH thiol alkynyl modified peptide nucleic acid
![[advanced data mining technology] Introduction to advanced data mining technology](/img/93/cb5ee07bff50662ad2496ca2bb39da.png)
[advanced data mining technology] Introduction to advanced data mining technology

Substr and substring function usage in SQL

Alibaba Sentinel 基操

Evolution of network IO model
随机推荐
[advanced data processing technology] data filtering, advanced data filling, initial and advanced data transformation
Easy to use office network optimization tool onedns
Lunch break train & problem thinking: on multidimensional array statistics of the number of elements
Unity's ugui text component hard row display (improved)
PHP page Jump mode
Azide labeled PNA peptide nucleic acid | methylene blue labeled PNA peptide nucleic acid | tyrosine modified PNA | Tyr PNA Qiyue Bio
Valdo2021 - vascular space segmentation in vascular disease detection challenge (2)
API data interface of A-share transaction data
Markdown to PDF API data interface
Lua environment configuration
Evolution of network IO model
[training Day8] series [matrix multiplication]
Near infrared dye cy7.5 labeling PNA polypeptide experimental steps cy7.5-pna|188re labeling anti gene peptide nucleic acid (agpna)
Valdo2021 - vascular space segmentation in vascular disease detection challenge (I)
1. Mx6u-alpha development board (buzzer experiment)
How to use named slots
微服务架构 | 服务监控与隔离 - [Sentinel] TBC...
[msp430g2553] graphical development notes (2) system clock and low power consumption mode
OpenGL (1) vertex buffer
Synthesis of peptide nucleic acid PNA labeled with heptachydrin dye cy7 cy7-pna