高!太高了!
2023-08-23 15:21:20
发布于:浙江
5阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int n = 2, a[5], s;
queue<int> q;
void bfs() {
q.push(0);
int c = 0;
while (q.size()) {
c++;
int f = q.front(); q.pop();
if (f == s) {printf("%d\n", f); exit(0);}
q.push(f + a[c]);
q.push(f);
}
}
int main() {
for (int i = 1;i <= n; i++) scanf("%d", &a[i]), s += a[i];
bfs();
return 0;
}
这里空空如也
有帮助,赞一个