Pagini recente » Clasament remember-mihai-patrascu | Cod sursa (job #49554) | Cod sursa (job #703776) | Cod sursa (job #2740708) | Cod sursa (job #2986520)
#include <fstream>
#include <vector>
#define maximum 50001
using namespace std;
ifstream cin("economie.in");
ofstream cout("economie.out");
bool able_to_make[maximum];
vector<int> v, answer;
int main() {
int n;
cin >> n;
v.resize(n);
for(int i = 0; i < n; i ++) {
cin >> v[i];
}
sort(v.begin(), v.end());
able_to_make[0] = 1;
for(int i = 0; i < n; i ++) {
if(able_to_make[v[i]] == false) {
answer.push_back(v[i]);
for(int j = 0; j + v[i] < maximum; j ++) {
if(able_to_make[j] == true) {
able_to_make[j + v[i]] = true;
}
}
}
}
cout << answer.size() << '\n';
for(int number : answer) {
cout << number << '\n';
}
}