解析 微扰法贪心经典题 代码 #include <bits/stdc++.h> using namespace std; bool cmp(const string &x, const string &y) { return x + y > y + x; } int main() { int n; while (~scanf("%d", &n) && n) { string str[55]; for (int i = 1; i…
https://vjudge.net/problem/UVA-11039 题意: 有n个绝对值各不相同的非0整数,选出尽量多的数,排成一个序列,使得正负号交替且绝对值递增. 思路:正数存一个数组,负数存一个数组,排序后进行遍历即可. #include<iostream> #include<algorithm> #include<string> using namespace std; + ; int n; int a[maxn],b[maxn]; int main()…