/* HDU 6168 - Numbers [ 思维 ] | 2017 ZJUT Multi-University Training 9 题意: .... 分析: 全放入multiset 从小到大,慢慢筛 */ #include <bits/stdc++.h> using namespace std; const int N = 125250; int n, s[N]; int a[N], cnt; multiset<int> st; multiset<int>::iterator it, pos; int main() { int x; while (~scanf("%d", &n)) { st.clear(); for (int i = 1; i <= n; ++i) { scanf("%d", &x); st.insert(x); } cnt = 0; for (it = st.begin(); it != st.end(); it++) { a[++cnt] = *it; for (int i = 1; i < cnt; i++) { pos = st.find(a[i]+a[cnt]); st.erase(pos); } } printf("%d\n", cnt); for (int i = 1; i < cnt; i++) printf("%d ", a[i]); if (cnt) printf("%d\n", a[cnt]); } }
时间: 2024-10-17 13:06:55