文章
30
粉丝
0
获赞
17
访问
3.6k
#include <iostream>
#include <map>
#include <cctype> // for isalpha, tolower
#include <string>
#include<algorithm>
#include<stack>
#include<stdlib.h> //C打印库函数
#include<climits>//climits中的最大最小值
#include<vector>
#include<queue>
#include<set>
using namespace std;
int n,s,temp;
vector<int> w;
bool dfs(int i, int remaining) {
if (remaining == 0) return true; // 找到了
if (i >= n || remaining < 0) return false; // 越界或超了
// 剪支
// 选 w[i]
if (dfs(i + 1, remaining - w[i]))
return true;
// 不选 w[i]
if (dfs(i + 1, remaining))
return true;
return false;
}
int main() {
cin>&g...
登录后发布评论
暂无评论,来抢沙发