文章
5
粉丝
63
获赞
13
访问
5.8k
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int weight[10000];
int S;
int n;
bool flag = false;
void traceback(int w, int i) {
    //cout << w << endl;
    if (w == S) {
        flag = true;
        return;
    }
    else if (w > S) {
        return;
    }
    else if (w < S) {
        for (int j = i; j < n; j++) {
            w += weight[j];
             traceback(w, j + 1);
             w -= weight[j];
        }
    }
}
int main(void) {
    cin >> S;...
登录后发布评论
暂无评论,来抢沙发