HDU 6168 - Numbers | 2017 ZJUT Multi-University Training 9
Posted nicetomeetu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDU 6168 - Numbers | 2017 ZJUT Multi-University Training 9相关的知识,希望对你有一定的参考价值。
/* 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]); } }
以上是关于HDU 6168 - Numbers | 2017 ZJUT Multi-University Training 9的主要内容,如果未能解决你的问题,请参考以下文章