为什么会停止工作呀,求助
查看原帖
为什么会停止工作呀,求助
255169
__LePetitPrince__楼主2023/8/6 14:49
#include <iostream>
using namespace std;
const int S = 100005;
int n, a[S], ans = 0;
void dfs(int x, int l, int last) {
	if (x == n + 1) {
		ans = max(ans, l);
	}
	if (a[last] & a[x] != 0) {
		dfs(x + 1, l + 1, x);
	}
	dfs(x + 1, l, last);
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	a[0] = 2147483637; // 2 ^ 31
	dfs(1, 0, 0);
	cout << ans;
	return 0;
}

我搜索就没写对过

2023/8/6 14:49
加载中...