求教
  • 板块学术版
  • 楼主Xu_Jinyi_2011
  • 当前回复12
  • 已保存回复12
  • 发布时间2024/8/27 11:23
  • 上次更新2024/8/27 14:20:36
查看原帖
求教
1136033
Xu_Jinyi_2011楼主2024/8/27 11:23

组合型枚举

正常递归解法,但是为什么加了注释的那一行就过不了了呢? bb 好像也没有改变呀。

#include <iostream> 
#define int long long
using namespace std;
int a, d;
int b[20], c[20];

void calc(int x, int y){
	if (x == a){
		for (int i = 0; i < x; i ++){
			cout << c[i] << ' ';
		}
		puts("");
	}
	for (int i = y + 1; i <= d; i ++){
//		if (b[i] > 0) continue;  // 为什么加了这一行就过不了了呢? 
		c[x] = i;
		calc(x + 1, i);
	}
}

signed main(){
	cin >> d >> a;
	calc(0, 0);
	return 0;
}
2024/8/27 11:23
加载中...