标签:str style names pac algorithm algo 复试上机 复试 路径
#include <iostream> #include <set> using namespace std; int main() { string s; while (cin >> s) { set<string> ss; string str; int i; for (i = 0; i < s.length() - 1; i++) { str += s[i]; if (s[i] != s[i + 1]) { ss.insert(str); str = ""; } } str += s[i]; ss.insert(str); for (auto it = ss.begin(); it != ss.end(); it++) cout << *it << endl; } return 0; }
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n, i, sum; vector<int> v; while (cin >> n) { int a[n]; for (i = 0; i < n; i++) { cin >> a[i]; v.push_back(a[i]); } sort(v.begin(), v.end()); sum = 0; while (v.size() != 1) { sum += (v[0] + v[1]); v.push_back(v[0] + v[1]); v.erase(v.begin()); v.erase(v.begin()); sort(v.begin(), v.end()); } cout << sum << endl; } return 0; }
标签:str style names pac algorithm algo 复试上机 复试 路径
原文地址:https://www.cnblogs.com/ache/p/12630066.html