状压DP

状压DP

状压 DP 是动态规划的一种,通过将状态压缩为整数来达到优化转移的目的

枚举状态中的子集

利用x = (x - 1) & s 来不重不漏的找子集

void find_subset(int s){
	int x = s;
	while(x){
		x = (x - 1) & s;
		cout << x << '\n';
	}
	return ;
}

相关资料

oi wiki 状压DP

例题

posted @ 2023-09-24 21:30  Qiansui  阅读(48)  评论(0)    收藏  举报